Mercurial > vim
comparison src/if_python.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 |
---|---|
68 | 68 |
69 #if !defined(PY_VERSION_HEX) || PY_VERSION_HEX < 0x02050000 | 69 #if !defined(PY_VERSION_HEX) || PY_VERSION_HEX < 0x02050000 |
70 # undef PY_SSIZE_T_CLEAN | 70 # undef PY_SSIZE_T_CLEAN |
71 #endif | 71 #endif |
72 | 72 |
73 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
74 # include "macglue.h" | |
75 # include <CodeFragments.h> | |
76 #endif | |
77 #undef main /* Defined in python.h - aargh */ | 73 #undef main /* Defined in python.h - aargh */ |
78 #undef HAVE_FCNTL_H /* Clash with os_win32.h */ | 74 #undef HAVE_FCNTL_H /* Clash with os_win32.h */ |
79 | 75 |
80 #define PyBytes_FromString PyString_FromString | 76 #define PyBytes_FromString PyString_FromString |
81 #define PyBytes_Check PyString_Check | 77 #define PyBytes_Check PyString_Check |
946 /* Disable implicit 'import site', because it may cause Vim to exit | 942 /* Disable implicit 'import site', because it may cause Vim to exit |
947 * when it can't be found. */ | 943 * when it can't be found. */ |
948 Py_NoSiteFlag++; | 944 Py_NoSiteFlag++; |
949 #endif | 945 #endif |
950 | 946 |
951 #if !defined(MACOS) || defined(MACOS_X_UNIX) | |
952 Py_Initialize(); | 947 Py_Initialize(); |
953 #else | |
954 PyMac_Initialize(); | |
955 #endif | |
956 | 948 |
957 #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 | 949 #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 |
958 /* 'import site' explicitly. */ | 950 /* 'import site' explicitly. */ |
959 site = PyImport_ImportModule("site"); | 951 site = PyImport_ImportModule("site"); |
960 if (site == NULL) | 952 if (site == NULL) |
1022 DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) | 1014 DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) |
1023 { | 1015 { |
1024 #ifndef PY_CAN_RECURSE | 1016 #ifndef PY_CAN_RECURSE |
1025 static int recursive = 0; | 1017 static int recursive = 0; |
1026 #endif | 1018 #endif |
1027 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
1028 GrafPtr oldPort; | |
1029 #endif | |
1030 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) | 1019 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
1031 char *saved_locale; | 1020 char *saved_locale; |
1032 #endif | 1021 #endif |
1033 #ifdef PY_CAN_RECURSE | 1022 #ifdef PY_CAN_RECURSE |
1034 PyGILState_STATE pygilstate; | 1023 PyGILState_STATE pygilstate; |
1043 ++recursive; | 1032 ++recursive; |
1044 #endif | 1033 #endif |
1045 if (python_end_called) | 1034 if (python_end_called) |
1046 return; | 1035 return; |
1047 | 1036 |
1048 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
1049 GetPort(&oldPort); | |
1050 /* Check if the Python library is available */ | |
1051 if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) | |
1052 goto theend; | |
1053 #endif | |
1054 if (Python_Init()) | 1037 if (Python_Init()) |
1055 goto theend; | 1038 goto theend; |
1056 | 1039 |
1057 init_range(arg); | 1040 init_range(arg); |
1058 | 1041 |
1097 } | 1080 } |
1098 #endif | 1081 #endif |
1099 | 1082 |
1100 Python_Lock_Vim(); /* enter vim */ | 1083 Python_Lock_Vim(); /* enter vim */ |
1101 PythonIO_Flush(); | 1084 PythonIO_Flush(); |
1102 #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
1103 SetPort(oldPort); | |
1104 #endif | |
1105 | 1085 |
1106 theend: | 1086 theend: |
1107 #ifndef PY_CAN_RECURSE | 1087 #ifndef PY_CAN_RECURSE |
1108 --recursive; | 1088 --recursive; |
1109 #endif | 1089 #endif |