Example #1
0
/*
 * Free python.dll
 */
    static void
end_dynamic_python(void)
{
    if (hinstPython)
    {
	close_dll(hinstPython);
	hinstPython = 0;
    }
}
Example #2
0
/*
 * Free ruby.dll
 */
    static void
end_dynamic_ruby()
{
    if (hinstRuby)
    {
	close_dll(hinstRuby);
	hinstRuby = NULL;
    }
}
Example #3
0
/*
 * Free python.dll
 */
    static void
end_dynamic_python3(void)
{
    if (hinstPy3 != 0)
    {
	close_dll(hinstPy3);
	hinstPy3 = 0;
    }
}
Example #4
0
static void
end_dynamic_lua(void)
{
    if (hinstLua)
    {
        close_dll(hinstLua);
        hinstLua = 0;
    }
}
Example #5
0
/*
 * 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;
}
Example #6
0
/*
 * 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;
}
Example #7
0
/*
 * 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;
    void *ucs_as_encoded_string;

#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;
	}
    }

    /* 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)
	py_PyUnicode_AsEncodedString = ucs_as_encoded_string;
    else
    {
	close_dll(hinstPython);
	hinstPython = 0;
	if (verbose)
	    EMSG2(_(e_loadfunc), "PyUnicode_UCSX_*");
	return FAIL;
    }

    return OK;
}
Example #8
0
/*
 * 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;
}