From 59e53a564c3ad6d7787e1626882e069459ff1a79 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 19 Feb 1991 12:22:24 +0000 Subject: Turned the list of init calls into a table (see import.c). --- Modules/config.c.in | 102 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 25 deletions(-) diff --git a/Modules/config.c.in b/Modules/config.c.in index 60e1967..50cca43 100644 --- a/Modules/config.c.in +++ b/Modules/config.c.in @@ -1,5 +1,7 @@ /* Configurable Python configuration file */ +#include + #ifdef USE_STDWIN #include @@ -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 */ +}; -- cgit v0.12