X Tutup
Skip to content

Commit caa6380

Browse files
committed
The great renaming, phase two: all header files have been updated to
use the new names exclusively, and the linker will see the new names. Files that import "Python.h" also only see the new names. Files that import "allobjects.h" will continue to be able to use the old names, due to the inclusion (in allobjects.h) of "rename2.h".
1 parent 94390ec commit caa6380

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+985
-582
lines changed

Include/Python.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* Header file to be included by modules using new naming conventions */
2+
#define Py_USE_NEW_NAMES
23
#include "allobjects.h"
3-
#include "rename1.h"

Include/accessobject.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4646
#define AC_R_PUBLIC 0004
4747
#define AC_W_PUBLIC 0002
4848

49-
extern DL_IMPORT typeobject Accesstype;
49+
extern DL_IMPORT PyTypeObject Accesstype;
5050

51-
#define is_accessobject(v) ((v)->ob_type == &Accesstype)
51+
#define PyAccess_Check(v) ((v)->ob_type == &Accesstype)
5252

53-
object *newaccessobject PROTO((object *, object *, typeobject *, int));
54-
object *getaccessvalue PROTO((object *, object *));
55-
int setaccessvalue PROTO((object *, object *, object *));
53+
PyObject *newaccessobject Py_PROTO((PyObject *, PyObject *, PyTypeObject *, int));
54+
PyObject *getaccessvalue Py_PROTO((PyObject *, PyObject *));
55+
int setaccessvalue Py_PROTO((PyObject *, PyObject *, PyObject *));
5656

57-
void setaccessowner PROTO((object *, object *));
58-
object *cloneaccessobject PROTO((object *));
59-
int hasaccessvalue PROTO((object *));
57+
void setaccessowner Py_PROTO((PyObject *, PyObject *));
58+
PyObject *cloneaccessobject Py_PROTO((PyObject *));
59+
int hasaccessvalue Py_PROTO((PyObject *));
6060

61-
extern DL_IMPORT typeobject Anynumbertype, Anysequencetype, Anymappingtype;
61+
extern DL_IMPORT PyTypeObject Anynumbertype, Anysequencetype, Anymappingtype;
6262

6363
#ifdef __cplusplus
6464
}

Include/allobjects.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4949

5050
#include <stdio.h>
5151
#include <string.h>
52+
#include <errno.h>
5253

5354
#include "myproto.h"
5455

@@ -76,9 +77,17 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7677
#include "modsupport.h"
7778
#include "ceval.h"
7879

79-
extern void fatal PROTO((char *));
80+
extern void Py_FatalError Py_PROTO((char *));
81+
82+
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
83+
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
8084

8185
#ifdef __cplusplus
8286
}
8387
#endif
88+
89+
#ifndef Py_USE_NEW_NAMES
90+
#include "rename2.h"
91+
#endif
92+
8493
#endif /* !Py_ALLOBJECTS_H */

Include/bitset.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3434

3535
typedef BYTE *bitset;
3636

37-
bitset newbitset PROTO((int nbits));
38-
void delbitset PROTO((bitset bs));
37+
bitset newbitset Py_PROTO((int nbits));
38+
void delbitset Py_PROTO((bitset bs));
3939
#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
40-
int addbit PROTO((bitset bs, int ibit)); /* Returns 0 if already set */
41-
int samebitset PROTO((bitset bs1, bitset bs2, int nbits));
42-
void mergebitset PROTO((bitset bs1, bitset bs2, int nbits));
40+
int addbit Py_PROTO((bitset bs, int ibit)); /* Returns 0 if already set */
41+
int samebitset Py_PROTO((bitset bs1, bitset bs2, int nbits));
42+
void mergebitset Py_PROTO((bitset bs1, bitset bs2, int nbits));
4343

4444
#define BITSPERBYTE (8*sizeof(BYTE))
4545
#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)

Include/bltinmodule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3030

3131
/* Built-in module interface */
3232

33-
extern object *getbuiltindict PROTO(());
33+
extern PyObject *getbuiltindict Py_PROTO(());
3434

3535
#ifdef __cplusplus
3636
}

Include/ceval.h

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3030

3131
/* Interface to random parts in ceval.c */
3232

33-
object *call_object PROTO((object *, object *));
33+
PyObject *PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
3434

35-
object *getbuiltins PROTO((void));
36-
object *getglobals PROTO((void));
37-
object *getlocals PROTO((void));
38-
object *getowner PROTO((void));
39-
object *getframe PROTO((void));
40-
int getrestricted PROTO((void));
35+
PyObject *PyEval_GetBuiltins Py_PROTO((void));
36+
PyObject *PyEval_GetGlobals Py_PROTO((void));
37+
PyObject *PyEval_GetLocals Py_PROTO((void));
38+
PyObject *PyEval_GetOwner Py_PROTO((void));
39+
PyObject *PyEval_GetFrame Py_PROTO((void));
40+
int PyEval_GetRestricted Py_PROTO((void));
4141

42-
void flushline PROTO((void));
42+
void Py_FlushLine Py_PROTO((void));
4343

44-
int Py_AddPendingCall PROTO((int (*func) PROTO((ANY *)), ANY *arg));
45-
int Py_MakePendingCalls PROTO((void));
44+
int Py_AddPendingCall Py_PROTO((int (*func) Py_PROTO((ANY *)), ANY *arg));
45+
int Py_MakePendingCalls Py_PROTO((void));
4646

4747

4848
/* Interface for threads.
@@ -52,62 +52,64 @@ int Py_MakePendingCalls PROTO((void));
5252
threads to run as follows:
5353
5454
...preparations here...
55-
BGN_SAVE
55+
Py_BEGIN_ALLOW_THREADS
5656
...blocking system call here...
57-
END_SAVE
57+
Py_END_ALLOW_THREADS
5858
...interpret result here...
5959
60-
The BGN_SAVE/END_SAVE pair expands to a {}-surrounded block.
60+
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
61+
{}-surrounded block.
6162
To leave the block in the middle (e.g., with return), you must insert
6263
a line containing RET_SAVE before the return, e.g.
6364
6465
if (...premature_exit...) {
65-
RET_SAVE
66-
err_errno(IOError);
66+
Py_BLOCK_THREADS
67+
PyErr_SetFromErrno(PyExc_IOError);
6768
return NULL;
6869
}
6970
7071
An alternative is:
7172
72-
RET_SAVE
73+
Py_BLOCK_THREADS
7374
if (...premature_exit...) {
74-
err_errno(IOError);
75+
PyErr_SetFromErrno(PyExc_IOError);
7576
return NULL;
7677
}
77-
RES_SAVE
78+
Py_UNBLOCK_THREADS
7879
7980
For convenience, that the value of 'errno' is restored across
80-
END_SAVE and RET_SAVE.
81+
Py_END_ALLOW_THREADS and RET_SAVE.
8182
82-
WARNING: NEVER NEST CALLS TO BGN_SAVE AND END_SAVE!!!
83+
WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
84+
Py_END_ALLOW_THREADS!!!
8385
84-
The function init_save_thread() should be called only from
86+
The function PyEval_InitThreads() should be called only from
8587
initthread() in "threadmodule.c".
8688
8789
Note that not yet all candidates have been converted to use this
8890
mechanism!
8991
*/
9092

91-
extern void init_save_thread PROTO((void));
92-
extern object *save_thread PROTO((void));
93-
extern void restore_thread PROTO((object *));
93+
extern void PyEval_InitThreads Py_PROTO((void));
94+
extern PyObject *PyEval_SaveThread Py_PROTO((void));
95+
extern void PyEval_RestoreThread Py_PROTO((PyObject *));
9496

9597
#ifdef WITH_THREAD
9698

97-
#define BGN_SAVE { \
98-
object *_save; \
99-
_save = save_thread();
100-
#define RET_SAVE restore_thread(_save);
101-
#define RES_SAVE _save = save_thread();
102-
#define END_SAVE restore_thread(_save); \
99+
#define Py_BEGIN_ALLOW_THREADS { \
100+
PyObject *_save; \
101+
_save = PyEval_SaveThread();
102+
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
103+
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
104+
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
103105
}
104106

105107
#else /* !WITH_THREAD */
106108

107-
#define BGN_SAVE {
108-
#define RET_SAVE
109-
#define RES_SAVE
110-
#define END_SAVE }
109+
#define Py_BEGIN_ALLOW_THREADS {
110+
#define Py_BLOCK_THREADS
111+
#define Py_UNBLOCK_THREADS
112+
#define Py_END_ALLOW_THREADS }
111113

112114
#endif /* !WITH_THREAD */
113115

Include/cgensupport.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3232

3333
typedef char *string;
3434

35-
#define mknewlongobject(x) newintobject(x)
36-
#define mknewshortobject(x) newintobject((long)x)
37-
#define mknewfloatobject(x) newfloatobject(x)
38-
#define mknewcharobject(ch) mkvalue("c", ch)
39-
40-
extern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a));
41-
extern int getilongarg PROTO((object *args, int nargs, int i, long *p_a));
42-
extern int getishortarg PROTO((object *args, int nargs, int i, short *p_a));
43-
extern int getifloatarg PROTO((object *args, int nargs, int i, float *p_a));
44-
extern int getistringarg PROTO((object *args, int nargs, int i, string *p_a));
35+
#define mknewlongobject(x) PyInt_FromLong(x)
36+
#define mknewshortobject(x) PyInt_FromLong((long)x)
37+
#define mknewfloatobject(x) PyFloat_FromDouble(x)
38+
#define mknewcharobject(ch) Py_BuildValue("c", ch)
39+
40+
extern int PyArg_GetObject Py_PROTO((PyObject *args, int nargs, int i, PyObject **p_a));
41+
extern int PyArg_GetLong Py_PROTO((PyObject *args, int nargs, int i, long *p_a));
42+
extern int PyArg_GetShort Py_PROTO((PyObject *args, int nargs, int i, short *p_a));
43+
extern int PyArg_GetFloat Py_PROTO((PyObject *args, int nargs, int i, float *p_a));
44+
extern int PyArg_GetString Py_PROTO((PyObject *args, int nargs, int i, string *p_a));
4545

4646
#ifdef __cplusplus
4747
}

Include/classobject.h

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,42 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3939
/* Revealing some structures (not for general use) */
4040

4141
typedef struct {
42-
OB_HEAD
43-
object *cl_bases; /* A tuple of class objects */
44-
object *cl_dict; /* A dictionary */
45-
object *cl_name; /* A string */
42+
PyObject_HEAD
43+
PyObject *cl_bases; /* A tuple of class objects */
44+
PyObject *cl_dict; /* A dictionary */
45+
PyObject *cl_name; /* A string */
4646
/* The following three are functions or NULL */
47-
object *cl_getattr;
48-
object *cl_setattr;
49-
object *cl_delattr;
50-
} classobject;
47+
PyObject *cl_getattr;
48+
PyObject *cl_setattr;
49+
PyObject *cl_delattr;
50+
} PyClassObject;
5151

5252
typedef struct {
53-
OB_HEAD
54-
classobject *in_class; /* The class object */
55-
object *in_dict; /* A dictionary */
56-
} instanceobject;
53+
PyObject_HEAD
54+
PyClassObject *in_class; /* The class object */
55+
PyObject *in_dict; /* A dictionary */
56+
} PyInstanceObject;
5757

58-
extern DL_IMPORT typeobject Classtype, Instancetype, Instancemethodtype;
58+
extern DL_IMPORT PyTypeObject PyClass_Type, PyInstance_Type, PyMethod_Type;
5959

60-
#define is_classobject(op) ((op)->ob_type == &Classtype)
61-
#define is_instanceobject(op) ((op)->ob_type == &Instancetype)
62-
#define is_instancemethodobject(op) ((op)->ob_type == &Instancemethodtype)
60+
#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
61+
#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
62+
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
6363

64-
extern object *newclassobject PROTO((object *, object *, object *));
65-
extern object *newinstanceobject PROTO((object *, object *));
66-
extern object *newinstancemethodobject PROTO((object *, object *, object *));
64+
extern PyObject *PyClass_New Py_PROTO((PyObject *, PyObject *, PyObject *));
65+
extern PyObject *PyInstance_New Py_PROTO((PyObject *, PyObject *));
66+
extern PyObject *PyMethod_New Py_PROTO((PyObject *, PyObject *, PyObject *));
6767

68-
extern object *instancemethodgetfunc PROTO((object *));
69-
extern object *instancemethodgetself PROTO((object *));
70-
extern object *instancemethodgetclass PROTO((object *));
68+
extern PyObject *PyMethod_Function Py_PROTO((PyObject *));
69+
extern PyObject *PyMethod_Self Py_PROTO((PyObject *));
70+
extern PyObject *PyMethod_Class Py_PROTO((PyObject *));
7171

72-
extern int issubclass PROTO((object *, object *));
72+
extern int PyClass_IsSubclass Py_PROTO((PyObject *, PyObject *));
7373

74-
extern object *instancebinop PROTO((object *, object *, char *, char *,
75-
object * (*) PROTO((object *, object *)) ));
74+
extern PyObject *instancebinop
75+
Py_PROTO((PyObject *, PyObject *,
76+
char *, char *,
77+
PyObject * (*) Py_PROTO((PyObject *, PyObject *)) ));
7678

7779
#ifdef __cplusplus
7880
}

Include/compile.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3939
- the name of the object for which it was compiled. */
4040

4141
typedef struct {
42-
OB_HEAD
43-
stringobject *co_code; /* instruction opcodes */
44-
object *co_consts; /* list of immutable constant objects */
45-
object *co_names; /* list of stringobjects */
46-
object *co_filename; /* string */
47-
object *co_name; /* string */
48-
} codeobject;
42+
PyObject_HEAD
43+
PyStringObject *co_code; /* instruction opcodes */
44+
PyObject *co_consts; /* list of immutable constant objects */
45+
PyObject *co_names; /* list of stringobjects */
46+
PyObject *co_filename; /* string */
47+
PyObject *co_name; /* string */
48+
} PyCodeObject;
4949

50-
extern DL_IMPORT typeobject Codetype;
50+
extern DL_IMPORT PyTypeObject PyCode_Type;
5151

52-
#define is_codeobject(op) ((op)->ob_type == &Codetype)
52+
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
5353

5454

5555
/* Public interface */
5656
struct _node; /* Declare the existence of this type */
57-
codeobject *compile PROTO((struct _node *, char *));
58-
codeobject *newcodeobject
59-
PROTO((object *, object *, object *, object *, object *));
57+
PyCodeObject *PyNode_Compile Py_PROTO((struct _node *, char *));
58+
PyCodeObject *PyCode_New
59+
Py_PROTO((PyObject *, PyObject *, PyObject *, PyObject *, PyObject *));
6060

6161
#ifdef __cplusplus
6262
}

Include/dictobject.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3232

3333
#include "mappingobject.h"
3434

35-
#define is_dictobject(op) is_mappingobject(op)
35+
#define PyDict_Check(op) is_mappingobject(op)
3636

37-
#define newdictobject newmappingobject
37+
#define newdictobject PyDict_New
3838

39-
extern object *dictlookup PROTO((object *dp, char *key));
40-
extern int dictinsert PROTO((object *dp, char *key, object *item));
41-
extern int dictremove PROTO((object *dp, char *key));
39+
extern PyObject *PyDict_GetItemString Py_PROTO((PyObject *dp, char *key));
40+
extern int PyDict_SetItemString Py_PROTO((PyObject *dp, char *key, PyObject *item));
41+
extern int PyDict_DelItemString Py_PROTO((PyObject *dp, char *key));
4242

43-
#define getdictkeys getmappingkeys
43+
#define getdictkeys PyDict_Keys
4444

45-
#define dict2lookup mappinglookup
46-
#define dict2insert mappinginsert
47-
#define dict2remove mappingremove
45+
#define dict2lookup PyDict_GetItem
46+
#define dict2insert PyDict_SetItem
47+
#define dict2remove PyDict_DelItem
4848

4949
#ifdef __cplusplus
5050
}

0 commit comments

Comments
 (0)
X Tutup