Index: Modules/pyvm.c =================================================================== --- Modules/pyvm.c (Revision 0) +++ Modules/pyvm.c (Revision 0) @@ -0,0 +1,92 @@ +/* pyvm module + Low level interface to Python's virtual machine and internal types. + + Copyright (c) 2007 by Christian Heimes + Licensed to PSF under a Contributor Agreement. + All rights reserved. +*/ + +#include "Python.h" +#include "frameobject.h" + +typedef struct _typeinfo { + PyTypeObject *type; + char *name; +} typeinfo; + +PyDoc_STRVAR(pyvm_doc, +"Python Virtual Machine module\n"); + +static PyMethodDef pyvm_methods[] = { + {NULL, NULL} /* sentinel */ +}; + +PyMODINIT_FUNC +initpyvm(void) +{ + char *name; + PyObject *mod; + typeinfo *ti; + typeinfo types[] = { + /* descriptors */ + {&PyClassMethodDescr_Type, NULL}, + {&PyGetSetDescr_Type, NULL}, + {&PyMemberDescr_Type, NULL}, + {&PyMethodDescr_Type, NULL}, + {&PyWrapperDescr_Type, NULL}, + /* functions */ + {&PyCFunction_Type, "builtin_method"}, + {&PyCFunction_Type, "builtin_function"}, /* alias */ + {&PyFunction_Type, NULL}, + {&PyMethod_Type, "instance_method"}, + /* dict */ + {&PyDictIterKey_Type, NULL}, + {&PyDictIterValue_Type, NULL}, + {&PyDictIterItem_Type, NULL}, + {&PyDictKeys_Type, NULL}, + {&PyDictItems_Type, NULL}, + {&PyDictValues_Type, NULL}, + {&PyDictProxy_Type, NULL}, + /* iter */ + {&PyBytesIter_Type, NULL}, + {&PyCallIter_Type, "callable_iterator"}, + {&PyLongRangeIter_Type, NULL}, + {&PyListIter_Type, NULL}, + {&PyListRevIter_Type, NULL}, + {&PyRangeIter_Type, NULL}, + {&PySeqIter_Type, NULL}, + {&PySetIter_Type, NULL}, + {&PyStringIter_Type, NULL}, + {&PyTupleIter_Type, NULL}, + {&PyUnicodeIter_Type, NULL}, + /* other */ + {&PyCObject_Type, NULL}, + {&PyCode_Type, NULL}, + {&PyFrame_Type, NULL}, + {&PyGen_Type, NULL}, + {&PyModule_Type, NULL}, + {&PyTraceBack_Type, NULL}, + {&PyCell_Type, NULL}, + {&PyEnum_Type, NULL}, + {&PyReversed_Type, NULL}, + {&PySortWrapper_Type, NULL}, + {&PyCmpWrapper_Type, NULL}, + /* sentinel */ + {NULL, NULL} + }; + + mod = Py_InitModule3("pyvm", pyvm_methods, pyvm_doc); + if (mod == NULL) + return; + + ti = types; + while(ti->type != NULL) { + name = ti->name; + if (name == NULL) + name = (char*)ti->type->tp_name; + assert(name); + Py_INCREF(ti->type); + PyModule_AddObject(mod, name, (PyObject *)ti->type); + ti++; + } +} Eigenschaftsänderungen: Modules/pyvm.c ___________________________________________________________________ Name: svn:keywords + Id Index: Modules/Setup.dist =================================================================== --- Modules/Setup.dist (Revision 59215) +++ Modules/Setup.dist (Arbeitskopie) @@ -113,6 +113,7 @@ errno errnomodule.c # posix (UNIX) errno values pwd pwdmodule.c # this is needed to find out the user's home dir # if $HOME is not set +pyvm pyvm.c # Python VM low level interface _sre _sre.c # Fredrik Lundh's new regular expressions _codecs _codecsmodule.c # access to the builtin codecs and codec registry _fileio _fileio.c # Standard I/O baseline