/* * Load library and get all pointers. * Parameter 'libname' provides name of DLL. * Return OK or FAIL. */ static int python_runtime_link_init(char *libname, int verbose) { int i; PYTHON_PROC *ucs_as_encoded_string = (PYTHON_PROC*)&py_PyUnicode_AsEncodedString; # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3) /* Can't have Python and Python3 loaded at the same time. * It cause a crash, because RTLD_GLOBAL is needed for * standard C extension libraries of one or both python versions. */ if (python3_loaded()) { if (verbose) emsg(_("E836: This Vim cannot execute :python after using :py3")); return FAIL; } # endif if (hinstPython) return OK; hinstPython = load_dll(libname); if (!hinstPython) { if (verbose) semsg(_(e_loadlib), libname); return FAIL; } for (i = 0; python_funcname_table[i].ptr; ++i) { if ((*python_funcname_table[i].ptr = symbol_from_dll(hinstPython, python_funcname_table[i].name)) == NULL) { close_dll(hinstPython); hinstPython = 0; if (verbose) semsg(_(e_loadfunc), python_funcname_table[i].name); return FAIL; } } /* Load unicode functions separately as only the ucs2 or the ucs4 functions * will be present in the library. */ *ucs_as_encoded_string = symbol_from_dll(hinstPython, "PyUnicodeUCS2_AsEncodedString"); if (*ucs_as_encoded_string == NULL) *ucs_as_encoded_string = symbol_from_dll(hinstPython, "PyUnicodeUCS4_AsEncodedString"); if (*ucs_as_encoded_string == NULL) { close_dll(hinstPython); hinstPython = 0; if (verbose) semsg(_(e_loadfunc), "PyUnicode_UCSX_*"); return FAIL; } return OK; }
/* * Load library and get all pointers. * Parameter 'libname' provides name of DLL. * Return OK or FAIL. */ static int ruby_runtime_link_init(char *libname, int verbose) { int i; if (hinstRuby) return OK; hinstRuby = load_dll(libname); if (!hinstRuby) { if (verbose) EMSG2(_(e_loadlib), libname); return FAIL; } for (i = 0; ruby_funcname_table[i].ptr; ++i) { if (!(*ruby_funcname_table[i].ptr = symbol_from_dll(hinstRuby, ruby_funcname_table[i].name))) { close_dll(hinstRuby); hinstRuby = NULL; if (verbose) EMSG2(_(e_loadfunc), ruby_funcname_table[i].name); return FAIL; } } return OK; }
static int lua_link_init(char *libname, int verbose) { const luaV_Reg *reg; if (hinstLua) return OK; hinstLua = load_dll(libname); if (!hinstLua) { if (verbose) EMSG2(_(e_loadlib), libname); return FAIL; } for (reg = luaV_dll; reg->func; reg++) { if ((*reg->func = symbol_from_dll(hinstLua, reg->name)) == NULL) { close_dll(hinstLua); hinstLua = 0; if (verbose) EMSG2(_(e_loadfunc), reg->name); return FAIL; } } return OK; }
/* * Load library and get all pointers. * Parameter 'libname' provides name of DLL. * Return OK or FAIL. */ static int python_runtime_link_init(char *libname, int verbose) { int i; #if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3) /* Can't have Python and Python3 loaded at the same time. * It cause a crash, because RTLD_GLOBAL is needed for * standard C extension libraries of one or both python versions. */ if (python3_loaded()) { if (verbose) EMSG(_("E836: This Vim cannot execute :python after using :py3")); return FAIL; } #endif if (hinstPython) return OK; hinstPython = load_dll(libname); if (!hinstPython) { if (verbose) EMSG2(_(e_loadlib), libname); return FAIL; } for (i = 0; python_funcname_table[i].ptr; ++i) { if ((*python_funcname_table[i].ptr = symbol_from_dll(hinstPython, python_funcname_table[i].name)) == NULL) { close_dll(hinstPython); hinstPython = 0; if (verbose) EMSG2(_(e_loadfunc), python_funcname_table[i].name); return FAIL; } } return OK; }
/* * Load library and get all pointers. * Parameter 'libname' provides name of DLL. * Return OK or FAIL. */ static int py3_runtime_link_init(char *libname, int verbose) { int i; void *ucs_from_string, *ucs_from_string_and_size; #if defined(UNIX) && defined(FEAT_PYTHON) /* Can't have Python and Python3 loaded at the same time, it may cause a * crash. */ if (python_loaded()) { EMSG(_("E999: Python: Cannot use :py and :py3 in one session")); return FAIL; } #endif if (hinstPy3 != 0) return OK; hinstPy3 = load_dll(libname); if (!hinstPy3) { if (verbose) EMSG2(_(e_loadlib), libname); return FAIL; } for (i = 0; py3_funcname_table[i].ptr; ++i) { if ((*py3_funcname_table[i].ptr = symbol_from_dll(hinstPy3, py3_funcname_table[i].name)) == NULL) { close_dll(hinstPy3); hinstPy3 = 0; if (verbose) EMSG2(_(e_loadfunc), py3_funcname_table[i].name); return FAIL; } } /* Load unicode functions separately as only the ucs2 or the ucs4 functions * will be present in the library. */ ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString"); ucs_from_string_and_size = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromStringAndSize"); if (!ucs_from_string || !ucs_from_string_and_size) { ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS4_FromString"); ucs_from_string_and_size = symbol_from_dll(hinstPy3, "PyUnicodeUCS4_FromStringAndSize"); } if (ucs_from_string && ucs_from_string_and_size) { py3_PyUnicode_FromString = ucs_from_string; py3_PyUnicode_FromStringAndSize = ucs_from_string_and_size; } else { close_dll(hinstPy3); hinstPy3 = 0; if (verbose) EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*"); return FAIL; } return OK; }
/* * Load library and get all pointers. * Parameter 'libname' provides name of DLL. * Return OK or FAIL. */ static int py3_runtime_link_init(char *libname, int verbose) { int i; void *ucs_from_string, *ucs_decode, *ucs_as_encoded_string; # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON) /* Can't have Python and Python3 loaded at the same time. * It cause a crash, because RTLD_GLOBAL is needed for * standard C extension libraries of one or both python versions. */ if (python_loaded()) { if (verbose) EMSG(_("E837: This Vim cannot execute :py3 after using :python")); return FAIL; } # endif if (hinstPy3 != 0) return OK; hinstPy3 = load_dll(libname); if (!hinstPy3) { if (verbose) EMSG2(_(e_loadlib), libname); return FAIL; } for (i = 0; py3_funcname_table[i].ptr; ++i) { if ((*py3_funcname_table[i].ptr = symbol_from_dll(hinstPy3, py3_funcname_table[i].name)) == NULL) { close_dll(hinstPy3); hinstPy3 = 0; if (verbose) EMSG2(_(e_loadfunc), py3_funcname_table[i].name); return FAIL; } } /* Load unicode functions separately as only the ucs2 or the ucs4 functions * will be present in the library. */ # if PY_VERSION_HEX >= 0x030300f0 ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString"); ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode"); ucs_as_encoded_string = symbol_from_dll(hinstPy3, "PyUnicode_AsEncodedString"); # else ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_FromString"); ucs_decode = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_Decode"); ucs_as_encoded_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS2_AsEncodedString"); if (!ucs_from_string || !ucs_decode || !ucs_as_encoded_string) { ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS4_FromString"); ucs_decode = symbol_from_dll(hinstPy3, "PyUnicodeUCS4_Decode"); ucs_as_encoded_string = symbol_from_dll(hinstPy3, "PyUnicodeUCS4_AsEncodedString"); } # endif if (ucs_from_string && ucs_decode && ucs_as_encoded_string) { py3_PyUnicode_FromString = ucs_from_string; py3_PyUnicode_Decode = ucs_decode; py3_PyUnicode_AsEncodedString = ucs_as_encoded_string; } else { close_dll(hinstPy3); hinstPy3 = 0; if (verbose) EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*"); return FAIL; } return OK; }