comparison src/if_python.c @ 33531:1a769647d661

patch 9.0.2013: confusing ifdefs in if_<lang>.c Commit: https://github.com/vim/vim/commit/c97b3febc82c1ccacf5f328ed0bd81c8b850e97d Author: Ken Takata <kentkt@csc.jp> Date: Wed Oct 11 21:27:06 2023 +0200 patch 9.0.2013: confusing ifdefs in if_<lang>.c Problem: confusing ifdefs in if_<lang>.c Solution: refactor ifndefs to #ifdefs if_x: Avoid using #ifndef - #else - #endif Using #ifndef - #else - #endif is sometimes confusing. Use #ifdef - #else - #endif instead. closes: #13310 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ken Takata <kentkt@csc.jp>
author Christian Brabandt <cb@256bit.org>
date Wed, 11 Oct 2023 21:30:11 +0200
parents 924e9cb09df7
children
comparison
equal deleted inserted replaced
33530:17619194b11f 33531:1a769647d661
128 #if defined(DYNAMIC_PYTHON) || defined(PROTO) 128 #if defined(DYNAMIC_PYTHON) || defined(PROTO)
129 # ifndef DYNAMIC_PYTHON 129 # ifndef DYNAMIC_PYTHON
130 # define HINSTANCE long_u // for generating prototypes 130 # define HINSTANCE long_u // for generating prototypes
131 # endif 131 # endif
132 132
133 # ifndef MSWIN 133 # ifdef MSWIN
134 # define load_dll vimLoadLib
135 # define close_dll FreeLibrary
136 # define symbol_from_dll GetProcAddress
137 # define load_dll_error GetWin32Error
138 # else
134 # include <dlfcn.h> 139 # include <dlfcn.h>
135 # define FARPROC void* 140 # define FARPROC void*
136 # define HINSTANCE void* 141 # define HINSTANCE void*
137 # if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL) 142 # if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
138 # define load_dll(n) dlopen((n), RTLD_LAZY) 143 # define load_dll(n) dlopen((n), RTLD_LAZY)
140 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) 145 # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
141 # endif 146 # endif
142 # define close_dll dlclose 147 # define close_dll dlclose
143 # define symbol_from_dll dlsym 148 # define symbol_from_dll dlsym
144 # define load_dll_error dlerror 149 # define load_dll_error dlerror
145 # else
146 # define load_dll vimLoadLib
147 # define close_dll FreeLibrary
148 # define symbol_from_dll GetProcAddress
149 # define load_dll_error GetWin32Error
150 # endif 150 # endif
151 151
152 // This makes if_python.c compile without warnings against Python 2.5 152 // This makes if_python.c compile without warnings against Python 2.5
153 // on Win32 and Win64. 153 // on Win32 and Win64.
154 # undef PyRun_SimpleString 154 # undef PyRun_SimpleString
494 { 494 {
495 char *name; 495 char *name;
496 PYTHON_PROC *ptr; 496 PYTHON_PROC *ptr;
497 } python_funcname_table[] = 497 } python_funcname_table[] =
498 { 498 {
499 # ifndef PY_SSIZE_T_CLEAN 499 # ifdef PY_SSIZE_T_CLEAN
500 {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse},
501 {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
502 {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue},
503 # else
500 {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse}, 504 {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse},
501 {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple}, 505 {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
502 {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue}, 506 {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
503 # else
504 {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse},
505 {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
506 {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue},
507 # endif 507 # endif
508 {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free}, 508 {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free},
509 {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc}, 509 {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
510 {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString}, 510 {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
511 {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument}, 511 {"PyErr_BadArgument", (PYTHON_PROC*)&dll_PyErr_BadArgument},