mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.579
Problem: Can't compile with Python 2.5. Solution: Use PyCObject when Capsules are not available.
This commit is contained in:
@@ -56,7 +56,7 @@ static struct PyMethodDef OutputMethods[] = {
|
|||||||
/* name, function, calling, documentation */
|
/* name, function, calling, documentation */
|
||||||
{"write", OutputWrite, 1, ""},
|
{"write", OutputWrite, 1, ""},
|
||||||
{"writelines", OutputWritelines, 1, ""},
|
{"writelines", OutputWritelines, 1, ""},
|
||||||
{"flush", OutputFlush, 1, ""},
|
{"flush", OutputFlush, 1, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -506,8 +506,8 @@ static struct PyMethodDef VimMethods[] = {
|
|||||||
/* name, function, calling, documentation */
|
/* name, function, calling, documentation */
|
||||||
{"command", VimCommand, 1, "Execute a Vim ex-mode command" },
|
{"command", VimCommand, 1, "Execute a Vim ex-mode command" },
|
||||||
{"eval", VimEval, 1, "Evaluate an expression using Vim evaluator" },
|
{"eval", VimEval, 1, "Evaluate an expression using Vim evaluator" },
|
||||||
{"bindeval", VimEvalPy, 1, "Like eval(), but returns objects attached to vim ones"},
|
{"bindeval", VimEvalPy, 1, "Like eval(), but returns objects attached to vim ones"},
|
||||||
{"strwidth", VimStrwidth, 1, "Screen string width, counts <Tab> as having width 1"},
|
{"strwidth", VimStrwidth, 1, "Screen string width, counts <Tab> as having width 1"},
|
||||||
{ NULL, NULL, 0, NULL }
|
{ NULL, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2432,17 +2432,32 @@ typedef int (*pytotvfunc)(PyObject *, typval_T *, PyObject *);
|
|||||||
convert_dl(PyObject *obj, typval_T *tv,
|
convert_dl(PyObject *obj, typval_T *tv,
|
||||||
pytotvfunc py_to_tv, PyObject *lookupDict)
|
pytotvfunc py_to_tv, PyObject *lookupDict)
|
||||||
{
|
{
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
PyObject *capsule;
|
PyObject *capsule;
|
||||||
|
# else
|
||||||
|
PyCObject *cobject;
|
||||||
|
# endif
|
||||||
char hexBuf[sizeof(void *) * 2 + 3];
|
char hexBuf[sizeof(void *) * 2 + 3];
|
||||||
|
|
||||||
sprintf(hexBuf, "%p", obj);
|
sprintf(hexBuf, "%p", obj);
|
||||||
|
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
capsule = PyDict_GetItemString(lookupDict, hexBuf);
|
capsule = PyDict_GetItemString(lookupDict, hexBuf);
|
||||||
if (capsule == NULL)
|
if (capsule == NULL)
|
||||||
|
# else
|
||||||
|
cobject = (PyCObject *)PyDict_GetItemString(lookupDict, hexBuf);
|
||||||
|
if (cobject == NULL)
|
||||||
|
# endif
|
||||||
{
|
{
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
capsule = PyCapsule_New(tv, NULL, NULL);
|
capsule = PyCapsule_New(tv, NULL, NULL);
|
||||||
PyDict_SetItemString(lookupDict, hexBuf, capsule);
|
PyDict_SetItemString(lookupDict, hexBuf, capsule);
|
||||||
Py_DECREF(capsule);
|
Py_DECREF(capsule);
|
||||||
|
# else
|
||||||
|
cobject = PyCObject_FromVoidPtr(tv, NULL);
|
||||||
|
PyDict_SetItemString(lookupDict, hexBuf, cobject);
|
||||||
|
Py_DECREF(cobject);
|
||||||
|
# endif
|
||||||
if (py_to_tv(obj, tv, lookupDict) == -1)
|
if (py_to_tv(obj, tv, lookupDict) == -1)
|
||||||
{
|
{
|
||||||
tv->v_type = VAR_UNKNOWN;
|
tv->v_type = VAR_UNKNOWN;
|
||||||
@@ -2458,7 +2473,13 @@ convert_dl(PyObject *obj, typval_T *tv,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typval_T *v = PyCapsule_GetPointer(capsule, NULL);
|
typval_T *v;
|
||||||
|
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
|
v = PyCapsule_GetPointer(capsule, NULL);
|
||||||
|
# else
|
||||||
|
v = PyCObject_AsVoidPtr(cobject);
|
||||||
|
# endif
|
||||||
copy_tv(v, tv);
|
copy_tv(v, tv);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -71,6 +71,10 @@ struct PyMethodDef { Py_ssize_t a; };
|
|||||||
# define PySequenceMethods Py_ssize_t
|
# define PySequenceMethods Py_ssize_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
|
||||||
|
# define PY_USE_CAPSULE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000
|
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000
|
||||||
# define PyInt Py_ssize_t
|
# define PyInt Py_ssize_t
|
||||||
# define PyInquiry lenfunc
|
# define PyInquiry lenfunc
|
||||||
@@ -220,8 +224,13 @@ struct PyMethodDef { Py_ssize_t a; };
|
|||||||
# define PyObject_Malloc dll_PyObject_Malloc
|
# define PyObject_Malloc dll_PyObject_Malloc
|
||||||
# define PyObject_Free dll_PyObject_Free
|
# define PyObject_Free dll_PyObject_Free
|
||||||
# endif
|
# endif
|
||||||
# define PyCapsule_New dll_PyCapsule_New
|
# ifdef PY_USE_CAPSULE
|
||||||
# define PyCapsule_GetPointer dll_PyCapsule_GetPointer
|
# define PyCapsule_New dll_PyCapsule_New
|
||||||
|
# define PyCapsule_GetPointer dll_PyCapsule_GetPointer
|
||||||
|
# else
|
||||||
|
# define PyCObject_FromVoidPtr dll_PyCObject_FromVoidPtr
|
||||||
|
# define PyCObject_AsVoidPtr dll_PyCObject_AsVoidPtr
|
||||||
|
# endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pointers for dynamic link
|
* Pointers for dynamic link
|
||||||
@@ -309,8 +318,13 @@ static int (*dll_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
|
|||||||
static void* (*dll_PyObject_Malloc)(size_t);
|
static void* (*dll_PyObject_Malloc)(size_t);
|
||||||
static void (*dll_PyObject_Free)(void*);
|
static void (*dll_PyObject_Free)(void*);
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
static PyObject* (*dll_PyCapsule_New)(void *, char *, PyCapsule_Destructor);
|
static PyObject* (*dll_PyCapsule_New)(void *, char *, PyCapsule_Destructor);
|
||||||
static void* (*dll_PyCapsule_GetPointer)(PyObject *, char *);
|
static void* (*dll_PyCapsule_GetPointer)(PyObject *, char *);
|
||||||
|
# else
|
||||||
|
static PyCObject* (*dll_PyCObject_FromVoidPtr)(void *cobj, void (*destr)(void *));
|
||||||
|
static void* (*dll_PyCObject_AsVoidPtr)(PyCObject *);
|
||||||
|
# endif
|
||||||
|
|
||||||
static HINSTANCE hinstPython = 0; /* Instance of python.dll */
|
static HINSTANCE hinstPython = 0; /* Instance of python.dll */
|
||||||
|
|
||||||
@@ -403,7 +417,8 @@ static struct
|
|||||||
{"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
|
{"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
|
||||||
{"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
|
{"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
|
||||||
{"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
|
{"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
|
||||||
# if (PY_VERSION_HEX >= 0x02050000) && SIZEOF_SIZE_T != SIZEOF_INT
|
# if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 \
|
||||||
|
&& SIZEOF_SIZE_T != SIZEOF_INT
|
||||||
{"Py_InitModule4_64", (PYTHON_PROC*)&dll_Py_InitModule4},
|
{"Py_InitModule4_64", (PYTHON_PROC*)&dll_Py_InitModule4},
|
||||||
# else
|
# else
|
||||||
{"Py_InitModule4", (PYTHON_PROC*)&dll_Py_InitModule4},
|
{"Py_InitModule4", (PYTHON_PROC*)&dll_Py_InitModule4},
|
||||||
@@ -424,8 +439,13 @@ static struct
|
|||||||
{"PyObject_Malloc", (PYTHON_PROC*)&dll_PyObject_Malloc},
|
{"PyObject_Malloc", (PYTHON_PROC*)&dll_PyObject_Malloc},
|
||||||
{"PyObject_Free", (PYTHON_PROC*)&dll_PyObject_Free},
|
{"PyObject_Free", (PYTHON_PROC*)&dll_PyObject_Free},
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef PY_USE_CAPSULE
|
||||||
{"PyCapsule_New", (PYTHON_PROC*)&dll_PyCapsule_New},
|
{"PyCapsule_New", (PYTHON_PROC*)&dll_PyCapsule_New},
|
||||||
{"PyCapsule_GetPointer", (PYTHON_PROC*)&dll_PyCapsule_GetPointer},
|
{"PyCapsule_GetPointer", (PYTHON_PROC*)&dll_PyCapsule_GetPointer},
|
||||||
|
# else
|
||||||
|
{"PyCObject_FromVoidPtr", (PYTHON_PROC*)&dll_PyCObject_FromVoidPtr},
|
||||||
|
{"PyCObject_AsVoidPtr", (PYTHON_PROC*)&dll_PyCObject_AsVoidPtr},
|
||||||
|
# endif
|
||||||
{"", NULL},
|
{"", NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -75,6 +75,9 @@ static void init_structs(void);
|
|||||||
# define CODEC_ERROR_HANDLER NULL
|
# define CODEC_ERROR_HANDLER NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Python 3 does not support CObjects, always use Capsules */
|
||||||
|
#define PY_USE_CAPSULE
|
||||||
|
|
||||||
#define PyInt Py_ssize_t
|
#define PyInt Py_ssize_t
|
||||||
#define PyString_Check(obj) PyUnicode_Check(obj)
|
#define PyString_Check(obj) PyUnicode_Check(obj)
|
||||||
#define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER)
|
#define PyString_AsBytes(obj) PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, CODEC_ERROR_HANDLER)
|
||||||
|
@@ -714,6 +714,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
579,
|
||||||
/**/
|
/**/
|
||||||
578,
|
578,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user