Mercurial > vim
comparison src/if_python3.c @ 12716:351cf7c67bbe v8.0.1236
patch 8.0.1236: Mac features are confusing
commit https://github.com/vim/vim/commit/d057301b1f28736f094affa17b190244ad56e8d9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 28 21:11:06 2017 +0200
patch 8.0.1236: Mac features are confusing
Problem: Mac features are confusing.
Solution: Make feature names more consistent, add "osxdarwin". Rename
feature flags, cleanup Mac code. (Kazunobu Kuriyama, closes #2178)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 28 Oct 2017 21:15:35 +0200 |
parents | 68d7bc045dbe |
children | 53cc7ea77c54 |
comparison
equal
deleted
inserted
replaced
12715:279ec0abb4ac | 12716:351cf7c67bbe |
---|---|
72 | 72 |
73 #define PY_SSIZE_T_CLEAN | 73 #define PY_SSIZE_T_CLEAN |
74 | 74 |
75 #include <Python.h> | 75 #include <Python.h> |
76 | 76 |
77 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
78 # include "macglue.h" | |
79 # include <CodeFragments.h> | |
80 #endif | |
81 #undef main /* Defined in python.h - aargh */ | 77 #undef main /* Defined in python.h - aargh */ |
82 #undef HAVE_FCNTL_H /* Clash with os_win32.h */ | 78 #undef HAVE_FCNTL_H /* Clash with os_win32.h */ |
83 | 79 |
84 /* The "surrogateescape" error handler is new in Python 3.1 */ | 80 /* The "surrogateescape" error handler is new in Python 3.1 */ |
85 #if PY_VERSION_HEX >= 0x030100f0 | 81 #if PY_VERSION_HEX >= 0x030100f0 |
869 Py_SetPythonHome(PYTHON3_HOME); | 865 Py_SetPythonHome(PYTHON3_HOME); |
870 #endif | 866 #endif |
871 | 867 |
872 PyImport_AppendInittab("vim", Py3Init_vim); | 868 PyImport_AppendInittab("vim", Py3Init_vim); |
873 | 869 |
874 #if !defined(MACOS) || defined(MACOS_X_UNIX) | |
875 Py_Initialize(); | 870 Py_Initialize(); |
876 #else | 871 |
877 PyMac_Initialize(); | |
878 #endif | |
879 /* Initialise threads, and below save the state using | 872 /* Initialise threads, and below save the state using |
880 * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread | 873 * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread |
881 * specific state (such as the system trace hook), will be lost | 874 * specific state (such as the system trace hook), will be lost |
882 * between invocations of Python code. */ | 875 * between invocations of Python code. */ |
883 PyEval_InitThreads(); | 876 PyEval_InitThreads(); |
927 * External interface | 920 * External interface |
928 */ | 921 */ |
929 static void | 922 static void |
930 DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) | 923 DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) |
931 { | 924 { |
932 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
933 GrafPtr oldPort; | |
934 #endif | |
935 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) | 925 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
936 char *saved_locale; | 926 char *saved_locale; |
937 #endif | 927 #endif |
938 PyObject *cmdstr; | 928 PyObject *cmdstr; |
939 PyObject *cmdbytes; | 929 PyObject *cmdbytes; |
940 PyGILState_STATE pygilstate; | 930 PyGILState_STATE pygilstate; |
941 | 931 |
942 if (python_end_called) | 932 if (python_end_called) |
943 goto theend; | 933 goto theend; |
944 | 934 |
945 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
946 GetPort(&oldPort); | |
947 /* Check if the Python library is available */ | |
948 if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) | |
949 goto theend; | |
950 #endif | |
951 if (Python3_Init()) | 935 if (Python3_Init()) |
952 goto theend; | 936 goto theend; |
953 | 937 |
954 init_range(arg); | 938 init_range(arg); |
955 | 939 |
990 } | 974 } |
991 #endif | 975 #endif |
992 | 976 |
993 Python_Lock_Vim(); /* enter vim */ | 977 Python_Lock_Vim(); /* enter vim */ |
994 PythonIO_Flush(); | 978 PythonIO_Flush(); |
995 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
996 SetPort(oldPort); | |
997 #endif | |
998 | 979 |
999 theend: | 980 theend: |
1000 return; /* keeps lint happy */ | 981 return; /* keeps lint happy */ |
1001 } | 982 } |
1002 | 983 |