Turned the list of init calls into a table (see import.c).

This commit is contained in:
Guido van Rossum 1991-02-19 12:22:24 +00:00
parent 865828d7cf
commit 59e53a564c
1 changed files with 77 additions and 25 deletions

View 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 */
};