Index: Include/descrobject.h =================================================================== --- Include/descrobject.h (Revision 59215) +++ Include/descrobject.h (Arbeitskopie) @@ -67,6 +67,10 @@ void *d_wrapped; /* This can be any function pointer */ } PyWrapperDescrObject; +PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; +PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; +PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; +PyAPI_DATA(PyTypeObject) PyMethodDescr_Type; PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); Index: Objects/descrobject.c =================================================================== --- Objects/descrobject.c (Revision 59216) +++ Objects/descrobject.c (Arbeitskopie) @@ -383,7 +383,7 @@ return 0; } -static PyTypeObject PyMethodDescr_Type = { +PyTypeObject PyMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "method_descriptor", sizeof(PyMethodDescrObject), @@ -421,7 +421,7 @@ }; /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ -static PyTypeObject PyClassMethodDescr_Type = { +PyTypeObject PyClassMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "classmethod_descriptor", sizeof(PyMethodDescrObject), @@ -458,7 +458,7 @@ 0, /* tp_descr_set */ }; -static PyTypeObject PyMemberDescr_Type = { +PyTypeObject PyMemberDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "member_descriptor", sizeof(PyMemberDescrObject), @@ -495,7 +495,7 @@ (descrsetfunc)member_set, /* tp_descr_set */ }; -static PyTypeObject PyGetSetDescr_Type = { +PyTypeObject PyGetSetDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "getset_descriptor", sizeof(PyGetSetDescrObject), Index: Makefile.pre.in =================================================================== --- Makefile.pre.in (Revision 59215) +++ Makefile.pre.in (Arbeitskopie) @@ -328,6 +328,7 @@ LIBRARY_OBJS= \ Modules/_typesmodule.o \ Modules/getbuildinfo.o \ + Modules/pyvm.o \ $(PARSER_OBJS) \ $(OBJECT_OBJS) \ $(PYTHON_OBJS) \ @@ -365,6 +366,7 @@ -rm -f $@ $(AR) cr $@ Modules/getbuildinfo.o $(AR) cr $@ Modules/_typesmodule.o + $(AR) cr $@ Modules/pyvm.o $(AR) cr $@ $(PARSER_OBJS) $(AR) cr $@ $(OBJECT_OBJS) $(AR) cr $@ $(PYTHON_OBJS) Index: Modules/pyvm.c =================================================================== --- Modules/pyvm.c (Revision 0) +++ Modules/pyvm.c (Revision 0) @@ -0,0 +1,69 @@ + + + +/* 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[] = { + /* descriptor types */ + {&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"}, + /* other */ + {&PyCode_Type, NULL}, + {&PyFrame_Type, NULL}, + {&PyGen_Type, NULL}, + {&PyModule_Type, NULL}, + {&PyTraceBack_Type, NULL}, + {&PyCallIter_Type, "callable_iterator"}, + {NULL, NULL} /* sentinel */ + }; + + 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