/* vi:set ts=8 sts=4 sw=4 noet: * * VIM - Vi IMproved by Bram Moolenaar * * Do ":help uganda" in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. * See README.txt for an overview of the Vim source code. *//* * Python extensions by Paul Moore. * Changes for Unix by David Leonard. * * This consists of four parts: * 1. Python interpreter main program * 2. Python output stream: writes output via [e]msg(). * 3. Implementation of the Vim module for Python * 4. Utility functions for handling the interface between Vim and Python. */#include"vim.h"#include<limits.h>/* Python.h defines _POSIX_THREADS itself (if needed) */#ifdef _POSIX_THREADS# undef _POSIX_THREADS#endif#if defined(_WIN32) && defined(HAVE_FCNTL_H)# undef HAVE_FCNTL_H#endif#ifdef _DEBUG# undef _DEBUG#endif#ifdef HAVE_STDARG_H# undef HAVE_STDARG_H /* Python's config.h defines it as well. */#endif#ifdef _POSIX_C_SOURCE# undef _POSIX_C_SOURCE /* pyconfig.h defines it as well. */#endif#ifdef _XOPEN_SOURCE# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */#endif#include<Python.h>#if defined(MACOS) && !defined(MACOS_X_UNIX)#include"macglue.h"#include<CodeFragments.h>#endif#undef main /* Defined in python.h - aargh */#undef HAVE_FCNTL_H /* Clash with os_win32.h */#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000# define PY_SSIZE_T_CLEAN#endifstaticvoidinit_structs(void);#define PyBytes_FromString PyString_FromString#define PyBytes_Check PyString_Check/* No-op conversion functions, use with care! */#define PyString_AsBytes(obj) (obj)#define PyString_FreeBytes(obj)#if !defined(FEAT_PYTHON) && defined(PROTO)/* Use this to be able to generate prototypes without python being used. */# define PyObject Py_ssize_t# define PyThreadState Py_ssize_t# define PyTypeObject Py_ssize_tstructPyMethodDef{Py_ssize_ta;};# define PySequenceMethods Py_ssize_t#endif#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000# define PY_USE_CAPSULE#endif#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000