mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
ANSI-fication of the sources.
This commit is contained in:
parent
1b190b4636
commit
ee238b977f
3 changed files with 33 additions and 79 deletions
|
@ -15,9 +15,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
#include "structmember.h"
|
#include "structmember.h"
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFunction_New(code, globals)
|
PyFunction_New(PyObject *code, PyObject *globals)
|
||||||
PyObject *code;
|
|
||||||
PyObject *globals;
|
|
||||||
{
|
{
|
||||||
PyFunctionObject *op = PyObject_NEW(PyFunctionObject,
|
PyFunctionObject *op = PyObject_NEW(PyFunctionObject,
|
||||||
&PyFunction_Type);
|
&PyFunction_Type);
|
||||||
|
@ -47,8 +45,7 @@ PyFunction_New(code, globals)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFunction_GetCode(op)
|
PyFunction_GetCode(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyFunction_Check(op)) {
|
if (!PyFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -58,8 +55,7 @@ PyFunction_GetCode(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFunction_GetGlobals(op)
|
PyFunction_GetGlobals(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyFunction_Check(op)) {
|
if (!PyFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -69,8 +65,7 @@ PyFunction_GetGlobals(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyFunction_GetDefaults(op)
|
PyFunction_GetDefaults(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyFunction_Check(op)) {
|
if (!PyFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -80,9 +75,7 @@ PyFunction_GetDefaults(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyFunction_SetDefaults(op, defaults)
|
PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
|
||||||
PyObject *op;
|
|
||||||
PyObject *defaults;
|
|
||||||
{
|
{
|
||||||
if (!PyFunction_Check(op)) {
|
if (!PyFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -118,9 +111,7 @@ static struct memberlist func_memberlist[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
func_getattr(op, name)
|
func_getattr(PyFunctionObject *op, char *name)
|
||||||
PyFunctionObject *op;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
if (name[0] != '_' && PyEval_GetRestricted()) {
|
if (name[0] != '_' && PyEval_GetRestricted()) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
|
@ -131,10 +122,7 @@ func_getattr(op, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
func_setattr(op, name, value)
|
func_setattr(PyFunctionObject *op, char *name, PyObject *value)
|
||||||
PyFunctionObject *op;
|
|
||||||
char *name;
|
|
||||||
PyObject *value;
|
|
||||||
{
|
{
|
||||||
if (PyEval_GetRestricted()) {
|
if (PyEval_GetRestricted()) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
|
@ -163,8 +151,7 @@ func_setattr(op, name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
func_dealloc(op)
|
func_dealloc(PyFunctionObject *op)
|
||||||
PyFunctionObject *op;
|
|
||||||
{
|
{
|
||||||
PyObject_GC_Fini(op);
|
PyObject_GC_Fini(op);
|
||||||
Py_DECREF(op->func_code);
|
Py_DECREF(op->func_code);
|
||||||
|
@ -177,8 +164,7 @@ func_dealloc(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
func_repr(op)
|
func_repr(PyFunctionObject *op)
|
||||||
PyFunctionObject *op;
|
|
||||||
{
|
{
|
||||||
char buf[140];
|
char buf[140];
|
||||||
if (op->func_name == Py_None)
|
if (op->func_name == Py_None)
|
||||||
|
@ -191,8 +177,7 @@ func_repr(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
func_compare(f, g)
|
func_compare(PyFunctionObject *f, PyFunctionObject *g)
|
||||||
PyFunctionObject *f, *g;
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
if (f->func_globals != g->func_globals)
|
if (f->func_globals != g->func_globals)
|
||||||
|
@ -210,8 +195,7 @@ func_compare(f, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
func_hash(f)
|
func_hash(PyFunctionObject *f)
|
||||||
PyFunctionObject *f;
|
|
||||||
{
|
{
|
||||||
long h,x;
|
long h,x;
|
||||||
h = PyObject_Hash(f->func_code);
|
h = PyObject_Hash(f->func_code);
|
||||||
|
|
|
@ -17,9 +17,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
static PyCFunctionObject *free_list = NULL;
|
static PyCFunctionObject *free_list = NULL;
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyCFunction_New(ml, self)
|
PyCFunction_New(PyMethodDef *ml, PyObject *self)
|
||||||
PyMethodDef *ml;
|
|
||||||
PyObject *self;
|
|
||||||
{
|
{
|
||||||
PyCFunctionObject *op;
|
PyCFunctionObject *op;
|
||||||
op = free_list;
|
op = free_list;
|
||||||
|
@ -39,8 +37,7 @@ PyCFunction_New(ml, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyCFunction
|
PyCFunction
|
||||||
PyCFunction_GetFunction(op)
|
PyCFunction_GetFunction(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyCFunction_Check(op)) {
|
if (!PyCFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -50,8 +47,7 @@ PyCFunction_GetFunction(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyCFunction_GetSelf(op)
|
PyCFunction_GetSelf(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyCFunction_Check(op)) {
|
if (!PyCFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -61,8 +57,7 @@ PyCFunction_GetSelf(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyCFunction_GetFlags(op)
|
PyCFunction_GetFlags(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
if (!PyCFunction_Check(op)) {
|
if (!PyCFunction_Check(op)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -74,8 +69,7 @@ PyCFunction_GetFlags(op)
|
||||||
/* Methods (the standard built-in methods, that is) */
|
/* Methods (the standard built-in methods, that is) */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meth_dealloc(m)
|
meth_dealloc(PyCFunctionObject *m)
|
||||||
PyCFunctionObject *m;
|
|
||||||
{
|
{
|
||||||
Py_XDECREF(m->m_self);
|
Py_XDECREF(m->m_self);
|
||||||
m->m_self = (PyObject *)free_list;
|
m->m_self = (PyObject *)free_list;
|
||||||
|
@ -83,9 +77,7 @@ meth_dealloc(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
meth_getattr(m, name)
|
meth_getattr(PyCFunctionObject *m, char *name)
|
||||||
PyCFunctionObject *m;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
if (strcmp(name, "__name__") == 0) {
|
if (strcmp(name, "__name__") == 0) {
|
||||||
return PyString_FromString(m->m_ml->ml_name);
|
return PyString_FromString(m->m_ml->ml_name);
|
||||||
|
@ -119,8 +111,7 @@ meth_getattr(m, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
meth_repr(m)
|
meth_repr(PyCFunctionObject *m)
|
||||||
PyCFunctionObject *m;
|
|
||||||
{
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
if (m->m_self == NULL)
|
if (m->m_self == NULL)
|
||||||
|
@ -134,8 +125,7 @@ meth_repr(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
meth_compare(a, b)
|
meth_compare(PyCFunctionObject *a, PyCFunctionObject *b)
|
||||||
PyCFunctionObject *a, *b;
|
|
||||||
{
|
{
|
||||||
if (a->m_self != b->m_self)
|
if (a->m_self != b->m_self)
|
||||||
return (a->m_self < b->m_self) ? -1 : 1;
|
return (a->m_self < b->m_self) ? -1 : 1;
|
||||||
|
@ -148,8 +138,7 @@ meth_compare(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static long
|
static long
|
||||||
meth_hash(a)
|
meth_hash(PyCFunctionObject *a)
|
||||||
PyCFunctionObject *a;
|
|
||||||
{
|
{
|
||||||
long x,y;
|
long x,y;
|
||||||
if (a->m_self == NULL)
|
if (a->m_self == NULL)
|
||||||
|
@ -189,8 +178,7 @@ PyTypeObject PyCFunction_Type = {
|
||||||
/* List all methods in a chain -- helper for findmethodinchain */
|
/* List all methods in a chain -- helper for findmethodinchain */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
listmethodchain(chain)
|
listmethodchain(PyMethodChain *chain)
|
||||||
PyMethodChain *chain;
|
|
||||||
{
|
{
|
||||||
PyMethodChain *c;
|
PyMethodChain *c;
|
||||||
PyMethodDef *ml;
|
PyMethodDef *ml;
|
||||||
|
@ -223,10 +211,7 @@ listmethodchain(chain)
|
||||||
/* Find a method in a method chain */
|
/* Find a method in a method chain */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
Py_FindMethodInChain(chain, self, name)
|
Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, char *name)
|
||||||
PyMethodChain *chain;
|
|
||||||
PyObject *self;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
if (name[0] == '_' && name[1] == '_') {
|
if (name[0] == '_' && name[1] == '_') {
|
||||||
if (strcmp(name, "__methods__") == 0)
|
if (strcmp(name, "__methods__") == 0)
|
||||||
|
@ -253,10 +238,7 @@ Py_FindMethodInChain(chain, self, name)
|
||||||
/* Find a method in a single method list */
|
/* Find a method in a single method list */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
Py_FindMethod(methods, self, name)
|
Py_FindMethod(PyMethodDef *methods, PyObject *self, char *name)
|
||||||
PyMethodDef *methods;
|
|
||||||
PyObject *self;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
PyMethodChain chain;
|
PyMethodChain chain;
|
||||||
chain.methods = methods;
|
chain.methods = methods;
|
||||||
|
@ -267,7 +249,7 @@ Py_FindMethod(methods, self, name)
|
||||||
/* Clear out the free list */
|
/* Clear out the free list */
|
||||||
|
|
||||||
void
|
void
|
||||||
PyCFunction_Fini()
|
PyCFunction_Fini(void)
|
||||||
{
|
{
|
||||||
while (free_list) {
|
while (free_list) {
|
||||||
PyCFunctionObject *v = free_list;
|
PyCFunctionObject *v = free_list;
|
||||||
|
|
|
@ -18,8 +18,7 @@ typedef struct {
|
||||||
} PyModuleObject;
|
} PyModuleObject;
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyModule_New(name)
|
PyModule_New(char *name)
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
PyModuleObject *m;
|
PyModuleObject *m;
|
||||||
PyObject *nameobj;
|
PyObject *nameobj;
|
||||||
|
@ -44,8 +43,7 @@ PyModule_New(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyModule_GetDict(m)
|
PyModule_GetDict(PyObject *m)
|
||||||
PyObject *m;
|
|
||||||
{
|
{
|
||||||
if (!PyModule_Check(m)) {
|
if (!PyModule_Check(m)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -55,8 +53,7 @@ PyModule_GetDict(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PyModule_GetName(m)
|
PyModule_GetName(PyObject *m)
|
||||||
PyObject *m;
|
|
||||||
{
|
{
|
||||||
PyObject *nameobj;
|
PyObject *nameobj;
|
||||||
if (!PyModule_Check(m)) {
|
if (!PyModule_Check(m)) {
|
||||||
|
@ -73,8 +70,7 @@ PyModule_GetName(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
PyModule_GetFilename(m)
|
PyModule_GetFilename(PyObject *m)
|
||||||
PyObject *m;
|
|
||||||
{
|
{
|
||||||
PyObject *fileobj;
|
PyObject *fileobj;
|
||||||
if (!PyModule_Check(m)) {
|
if (!PyModule_Check(m)) {
|
||||||
|
@ -91,8 +87,7 @@ PyModule_GetFilename(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_PyModule_Clear(m)
|
_PyModule_Clear(PyObject *m)
|
||||||
PyObject *m;
|
|
||||||
{
|
{
|
||||||
/* To make the execution order of destructors for global
|
/* To make the execution order of destructors for global
|
||||||
objects a bit more predictable, we first zap all objects
|
objects a bit more predictable, we first zap all objects
|
||||||
|
@ -142,8 +137,7 @@ _PyModule_Clear(m)
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
module_dealloc(m)
|
module_dealloc(PyModuleObject *m)
|
||||||
PyModuleObject *m;
|
|
||||||
{
|
{
|
||||||
if (m->md_dict != NULL) {
|
if (m->md_dict != NULL) {
|
||||||
_PyModule_Clear((PyObject *)m);
|
_PyModule_Clear((PyObject *)m);
|
||||||
|
@ -153,8 +147,7 @@ module_dealloc(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
module_repr(m)
|
module_repr(PyModuleObject *m)
|
||||||
PyModuleObject *m;
|
|
||||||
{
|
{
|
||||||
char buf[400];
|
char buf[400];
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -176,9 +169,7 @@ module_repr(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
module_getattr(m, name)
|
module_getattr(PyModuleObject *m, char *name)
|
||||||
PyModuleObject *m;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
if (strcmp(name, "__dict__") == 0) {
|
if (strcmp(name, "__dict__") == 0) {
|
||||||
|
@ -194,10 +185,7 @@ module_getattr(m, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
module_setattr(m, name, v)
|
module_setattr(PyModuleObject *m, char *name, PyObject *v)
|
||||||
PyModuleObject *m;
|
|
||||||
char *name;
|
|
||||||
PyObject *v;
|
|
||||||
{
|
{
|
||||||
if (name[0] == '_' && strcmp(name, "__dict__") == 0) {
|
if (name[0] == '_' && strcmp(name, "__dict__") == 0) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue