]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Turned the list of init calls into a table (see import.c).
authorGuido van Rossum <guido@python.org>
Tue, 19 Feb 1991 12:22:24 +0000 (12:22 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 19 Feb 1991 12:22:24 +0000 (12:22 +0000)
Modules/config.c.in

index 60e19673b14340aa4756ac18b16c18a56e81905f..50cca43ca82ab677ef36a5262a48a840ebcc8022 100644 (file)
@@ -1,5 +1,7 @@
 /* Configurable Python configuration file */
 
+#include <stdio.h>
+
 #ifdef USE_STDWIN
 #include <stdwin.h>
 
@@ -43,37 +45,13 @@ initargs(p_argc, p_argv)
        }
        
        if (use_stdwin)
-               winitargs(p_argc, p_argv);
+               wargs(p_argc, p_argv);
 #endif
 }
 
 void
 initcalls()
 {
-       inittime();
-       initmath();
-       initregexp();
-       initposix();
-
-#ifdef USE_AUDIO
-       initaudio();
-#endif
-
-#ifdef USE_AMOEBA
-       initamoeba();
-#endif
-
-#ifdef USE_GL
-       initgl();
-#ifdef USE_PANEL
-       initpanel();
-#endif
-#endif
-
-#ifdef USE_STDWIN
-       if (use_stdwin)
-               initstdwin();
-#endif
 }
 
 void
@@ -88,6 +66,18 @@ donecalls()
 #endif
 }
 
+#ifdef USE_STDWIN
+static void
+maybeinitstdwin()
+{
+       if (use_stdwin)
+               initstdwin();
+       else
+               fprintf(stderr,
+                "No $DISPLAY nor -display arg -- stdwin not available\n");
+}
+#endif
+
 #ifndef PYTHONPATH
 #define PYTHONPATH ".:/usr/local/lib/python"
 #endif
@@ -102,3 +92,65 @@ getpythonpath()
                path = PYTHONPATH;
        return path;
 }
+
+
+/* Table of built-in modules.
+   These are initialized when first imported. */
+
+/* Standard modules */
+extern void inittime();
+extern void initmath();
+extern void initregexp();
+extern void initposix();
+#ifdef USE_AUDIO
+extern void initaudio();
+#endif
+#ifdef USE_AMOEBA
+extern void initamoeba();
+#endif
+#ifdef USE_GL
+extern void initgl();
+#ifdef USE_PANEL
+extern void initpanel();
+#endif
+#endif
+#ifdef USE_STDWIN
+extern void maybeinitstdwin();
+#endif
+
+struct {
+       char *name;
+       void (*initfunc)();
+} inittab[] = {
+
+       /* Standard modules */
+
+       {"time",        inittime},
+       {"math",        initmath},
+       {"regexp",      initregexp},
+       {"posix",       initposix},
+
+
+       /* Optional modules */
+
+#ifdef USE_AUDIO
+       {"audio",       initaudio},
+#endif
+
+#ifdef USE_AMOEBA
+       {"amoeba",      initamoeba},
+#endif
+
+#ifdef USE_GL
+       {"gl",          initgl},
+#ifdef USE_PANEL
+       {"pnl",         initpanel},
+#endif
+#endif
+
+#ifdef USE_STDWIN
+       {"stdwin",      maybeinitstdwin},
+#endif
+
+       {0,             0}              /* Sentinel */
+};