Got the new structure working with MSVC 4.2.

main_nt.c is gone -- we can use Modules/python.c now.
Added Mark Hammond's module msvcrt.c (untested).
Added several new symbols.
This commit is contained in:
Guido van Rossum 1997-08-07 00:11:34 +00:00
parent fb84255e67
commit 29c1ea5af0
5 changed files with 192 additions and 3320 deletions

View File

@ -60,6 +60,9 @@ extern void inittime();
extern void initthread();
extern void initcStringIO();
extern void initcPickle();
#ifdef WIN32
extern void initmsvcrt();
#endif
/* -- ADDMODULE MARKER 1 -- */
@ -98,6 +101,9 @@ struct _inittab _PyImport_Inittab[] = {
#endif
{"cStringIO", initcStringIO},
{"cPickle", initcPickle},
#ifdef WIN32
{"msvcrt", initmsvcrt},
#endif
/* -- ADDMODULE MARKER 2 -- */

View File

@ -1,42 +0,0 @@
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Python interpreter main program */
extern int Py_Main(int, char **);
int
main(argc, argv)
int argc;
char **argv;
{
return Py_Main(argc, argv);
}

95
PC/msvcrtmodule.c Executable file
View File

@ -0,0 +1,95 @@
/*********************************************************
msvcrtmodule.c
A Python interface to the Microsoft Visual C Runtime
Library, providing access to those non-portable, but
still useful routines.
Only ever compiled with an MS compiler, so no attempt
has been made to avoid MS language extensions, etc...
***********************************************************/
#include "Python.h"
#include "malloc.h"
// Perform locking operations on a file.
static PyObject *msvcrt_locking(PyObject *self, PyObject *args)
{
int mode;
long nBytes;
PyObject *obFile;
FILE *pFile;
if (!PyArg_ParseTuple(args,"O!il:locking", &obFile, PyFile_Type, &mode, &nBytes))
return NULL;
if (NULL==(pFile = PyFile_AsFile(obFile)))
return NULL;
if (0 != _locking(_fileno(pFile), mode, nBytes))
return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None);
return Py_None;
}
// Forces the malloc heap to clean itself up, and free unused blocks
// back to the OS.
static PyObject *msvcrt_heapmin(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args,":heapmin"))
return NULL;
if (_heapmin()!=0)
return PyErr_SetFromErrno(PyExc_MemoryError); // Is this the correct error???
Py_INCREF(Py_None);
return Py_None;
}
/*******
Left this out for now...
// Convert an OS file handle to a Python file object (yay!).
// This may only work on NT
static PyObject *msvcrt_open_osfhandle(PyObject *self, PyObject *args)
{
// Note that we get the underlying handle using the long
// "abstract" interface. This will allow either a native integer
// or else a Win32 extension PyHANDLE object, which implements an
// int() converter.
PyObject *obHandle;
PyObject *obInt;
int flags;
long handle;
if (!PyArg_ParseTuple(args,"Oi:open_osfhandle", &obHandle, &flags))
return NULL;
if (NULL==(obInt = PyNumber_Int(obHandle))) {
PyErr_Clear();
PyErr_SetString(PyExc_TypeError, "The handle param must be an integer, =
or an object able to be converted to an integer");
return NULL;
}
handle = PyInt_AsLong(obInt);
Py_DECREF(obInt);
rtHandle = _open_osfhandle(handle, flags);
if (rtHandle==-1)
return PyErr_SetFromErrno(PyExc_IOError);
what mode? Should I just return here, and expose _fdopen
and setvbuf?
f1=_fdopen(fd1, "w");
setvbuf(f1, NULL, _IONBF, 0);
f=PyFile_FromFile(f1, cmdstring, "w", fclose);
}
*****/
/* List of functions exported by this module */
static struct PyMethodDef msvcrt_functions[] = {
{"locking", msvcrt_locking, 1},
{"heapmin", msvcrt_heapmin, 1},
{NULL, NULL}
};
__declspec(dllexport) void
initmsvcrt(void)
{
Py_InitModule("msvcrt", msvcrt_functions);
}

View File

@ -54,6 +54,8 @@ EXPORTS
PySlice_Type DATA
Py_InteractiveFlag DATA
PyCObject_Type DATA
Py_input_hook DATA
PyOS_ReadlineFunctionPointer DATA
_PyObject_New
_PyObject_NewVar
@ -196,21 +198,19 @@ EXPORTS
PyEval_ReleaseThread
PyEval_RestoreThread
PyEval_SaveThread
PyEval_AcquireLock
PyEval_ReleaseLock
PyTraceBack_Here
PyTraceBack_Print
PyImport_AddModule
PyImport_Cleanup
PyImport_GetModuleDict
PyImport_GetMagicNumber
PyImport_ImportModule
PyImport_ImportFrozenModule
PyImport_Init
PyImport_ReloadModule
PyNumber_Coerce
PyBuiltin_Init
PyMarshal_Init
Py_InitModule4
PySys_Init
PySys_SetArgv
PySys_SetPath
PySys_GetObject
@ -219,7 +219,6 @@ EXPORTS
Py_CompileString
Py_FatalError
Py_Exit
Py_Cleanup
Py_Initialize
PyErr_Print
PyParser_SimpleParseFile
@ -350,9 +349,17 @@ EXPORTS
PyThread_free_sema
PyThread_down_sema
PyThread_up_sema
PyThread_exit_prog
PyThread__exit_prog
PyThread_create_key
PyThread_delete_key
PyThread_get_key_value
PyThread_set_key_value
Py_NewInterpreter
Py_EndInterpreter
Py_Malloc
Py_Realloc
Py_Free
PyMem_Malloc
PyMem_Realloc
PyMem_Free
PyThreadState_New
PyThreadState_Clear
PyThreadState_Delete
PyInterpreterState_New
PyInterpreterState_Clear
PyInterpreterState_Delete

File diff suppressed because it is too large Load Diff