Mercurial > cpython-lru_cache-weakref
diff Mac/Python/macmain.c @ 4962:765d962f4449 legacy-trunk
Added PyMac_Initialize() routine, to be used by embedding programs (in
stead of standard Py_Initialize(), which it calls).
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Wed, 15 Jan 1997 15:49:08 +0000 |
| parents | 21878c849626 |
| children | d6b292a33cfe |
line wrap: on
line diff
--- a/Mac/Python/macmain.c Tue Jan 14 18:44:23 1997 +0000 +++ b/Mac/Python/macmain.c Wed Jan 15 15:49:08 1997 +0000 @@ -192,7 +192,7 @@ ** Initialization code, shared by interpreter and applets */ static void -init_common(int *argcp, char ***argvp) +init_common(int *argcp, char ***argvp, int embedded) { /* Remember resource fork refnum, for later */ PyMac_AppRefNum = CurResFile(); @@ -223,11 +223,18 @@ options.keep_error = 1; /* default-default */ PyMac_PreferenceOptions(&options); - /* Create argc/argv. Do it before we go into the options event loop. */ - *argcp = PyMac_GetArgv(argvp, options.noargs); - - /* Do interactive option setting, if allowed and <option> depressed */ - PyMac_InteractiveOptions(&options, argcp, argvp); + if ( embedded ) { + static char *emb_argv[] = {"embedded-python", 0}; + + *argcp = 1; + *argvp = emb_argv; + } else { + /* Create argc/argv. Do it before we go into the options event loop. */ + *argcp = PyMac_GetArgv(argvp, options.noargs); + + /* Do interactive option setting, if allowed and <option> depressed */ + PyMac_InteractiveOptions(&options, argcp, argvp); + } /* Copy selected options to where the machine-independent stuff wants it */ Py_VerboseFlag = options.verbose; @@ -310,7 +317,7 @@ char **argv; int err; - init_common(&argc, &argv); + init_common(&argc, &argv, 0); Py_Initialize(); PySys_SetArgv(argc, argv); @@ -325,6 +332,20 @@ /* XXX Should we bother to Py_Exit(sts)? */ } +/* +** Hook for embedding python. +*/ +void +PyMac_Initialize() +{ + int argc; + char **argv; + + init_common(&argc, &argv, 1); + Py_Initialize(); + PySys_SetArgv(argc, argv); +} + #endif /* USE_MAC_APPLET_SUPPORT */ /* For normal application */ @@ -334,7 +355,7 @@ int argc; char **argv; - init_common(&argc, &argv); + init_common(&argc, &argv, 0); if ( argc > 1 ) { /* We're running a script. Attempt to change current directory */
