On Wed, Aug 13, 2008 at 10:51:48AM -0700, Danek Duvall wrote:
> There's still the question of the language bindings. You could put them
> only into gvim for now, I suppose. I have a patch somewhere that turns the
> python binding into one that can be dynamically loaded, but it doesn't
> completely work.
FWIW, here's what I had. I still don't remember what it was I could do to
get it to crash, but there was, in fact, something.
Danek
-------------- next part --------------
--- if_python.c.orig Tue May 22 23:11:42 2007
+++ if_python.c Wed May 23 00:11:16 2007
@@ -65,6 +65,7 @@
# define PY_CAN_RECURSE
#endif
+#ifdef MSWIN
#if defined(DYNAMIC_PYTHON) || defined(PROTO)
# ifndef DYNAMIC_PYTHON
# define HINSTANCE int /* for generating prototypes */
@@ -350,7 +351,54 @@
Py_XDECREF(exmod);
}
#endif /* DYNAMIC_PYTHON */
+#endif /* MSWIN */
+#if defined(SOLARIS) && defined(DYNAMIC_PYTHON)
+#include <dlfcn.h>
+
+static void *python_dlhandle = NULL;
+
+static void
+end_dynamic_python(void)
+{
+ if (python_dlhandle) {
+ dlclose(python_dlhandle);
+ python_dlhandle = NULL;
+ }
+}
+
+static int
+python_runtime_link_init(char *libname, int verbose)
+{
+ /* printf("in link_init\n"); */
+ if (python_dlhandle) {
+ /* printf("python_dlhandle isn't null\n"); */
+ return OK;
+ }
+ python_dlhandle = dlopen(libname, RTLD_GLOBAL|RTLD_LAZY);
+ if (!python_dlhandle)
+ {
+ if (verbose)
+ EMSG2(_(e_loadlib), libname);
+ return FAIL;
+ }
+
+ return OK;
+}
+
+int
+python_enabled(int verbose)
+{
+ return python_runtime_link_init("libpython2.4.so.1.0", verbose) == OK;
+}
+
+static void
+get_exceptions()
+{
+ /* This doesn't need to do anything on Solaris */
+}
+#endif
+
/******************************************************
* Internal function prototypes.
*/
@@ -451,7 +499,13 @@
++recurse;
#ifdef DYNAMIC_PYTHON
- if (hinstPython && Py_IsInitialized())
+ if (
+#ifdef MSWIN
+ hinstPython
+#elif defined(SOLARIS)
+ python_dlhandle
+#endif
+ && Py_IsInitialized())
{
Python_RestoreThread(); /* enter python */
Py_Finalize();