[Python-checkins] CVS: python/dist/src/Include abstract.h,2.26,2.27 classobject.h,2.31,2.32 graminit.h,2.15,2.16 object.h,2.63,2.64 opcode.h,2.29,2.30 token.h,2.15,2.16
Thomas Wouters
python-dev@python.org
Thu, 24 Aug 2000 13:09:49 -0700
Update of /cvsroot/python/python/dist/src/Include
In directory slayer.i.sourceforge.net:/tmp/cvs-serv13301/Include
Modified Files:
abstract.h classobject.h graminit.h object.h opcode.h token.h
Log Message:
The real suport for augmented assignment: new opcodes, new PyNumber and
PySequence methods and functions, new tokens.
Index: abstract.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/abstract.h,v
retrieving revision 2.26
retrieving revision 2.27
diff -C2 -r2.26 -r2.27
*** abstract.h 2000/08/03 16:42:14 2.26
--- abstract.h 2000/08/24 20:09:45 2.27
***************
*** 665,669 ****
--- 665,771 ----
*/
+ /* In-place variants of (some of) the above number protocol functions */
+ DL_IMPORT(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of adding o2 to o1, possibly in-place, or null
+ on failure. This is the equivalent of the Python expression:
+ o1 += o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of subtracting o2 from o1, possibly in-place or
+ null on failure. This is the equivalent of the Python expression:
+ o1 -= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of multiplying o1 by o2, possibly in-place, or
+ null on failure. This is the equivalent of the Python expression:
+ o1 *= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of dividing o1 by o2, possibly in-place, or null
+ on failure. This is the equivalent of the Python expression:
+ o1 /= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the remainder of dividing o1 by o2, possibly in-place, or
+ null on failure. This is the equivalent of the Python expression:
+ o1 %= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
+ PyObject *o3);
+
+ /*
+ Returns the result of raising o1 to the power of o2, possibly
+ in-place, or null on failure. This is the equivalent of the Python
+ expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of left shifting o1 by o2, possibly in-place, or
+ null on failure. This is the equivalent of the Python expression:
+ o1 <<= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of right shifting o1 by o2, possibly in-place or
+ null on failure. This is the equivalent of the Python expression:
+ o1 >>= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of bitwise and of o1 and o2, possibly in-place,
+ or null on failure. This is the equivalent of the Python
+ expression: o1 &= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the bitwise exclusive or of o1 by o2, possibly in-place, or
+ null on failure. This is the equivalent of the Python expression:
+ o1 ^= o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
+
+ /*
+ Returns the result of bitwise or or o1 and o2, possibly in-place,
+ or null on failure. This is the equivalent of the Python
+ expression: o1 |= o2.
+
+ */
+
+
/* Sequence protocol:*/
***************
*** 823,826 ****
--- 925,948 ----
return -1. This is equivalent to the Python
expression: o.index(value).
+ */
+
+ /* In-place versions of some of the above Sequence functions. */
+
+ DL_IMPORT(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
+
+ /*
+ Append o2 to o1, in-place when possible. Return the resulting
+ object, which could be o1, or NULL on failure. This is the
+ equivalent of the Python expression: o1 += o2.
+
+ */
+
+ DL_IMPORT(PyObject *) PySequence_InPlaceRepeat(PyObject *o, int count);
+
+ /*
+ Repeat o1 by count, in-place when possible. Return the resulting
+ object, which could be o1, or NULL on failure. This is the
+ equivalent of the Python expression: o1 *= count.
+
*/
Index: classobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/classobject.h,v
retrieving revision 2.31
retrieving revision 2.32
diff -C2 -r2.31 -r2.32
*** classobject.h 2000/07/09 00:20:36 2.31
--- classobject.h 2000/08/24 20:09:45 2.32
***************
*** 74,77 ****
--- 74,81 ----
PyObject *));
+ extern DL_IMPORT(int)
+ PyInstance_HalfBinOp(PyObject *, PyObject *, char *, PyObject **,
+ PyObject * (*)(PyObject *, PyObject *), int);
+
#ifdef __cplusplus
}
Index: graminit.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/graminit.h,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** graminit.h 2000/08/17 22:54:59 2.15
--- graminit.h 2000/08/24 20:09:45 2.16
***************
*** 11,63 ****
#define small_stmt 266
#define expr_stmt 267
! #define print_stmt 268
! #define del_stmt 269
! #define pass_stmt 270
! #define flow_stmt 271
! #define break_stmt 272
! #define continue_stmt 273
! #define return_stmt 274
! #define raise_stmt 275
! #define import_stmt 276
! #define import_as_name 277
! #define dotted_as_name 278
! #define dotted_name 279
! #define global_stmt 280
! #define exec_stmt 281
! #define assert_stmt 282
! #define compound_stmt 283
! #define if_stmt 284
! #define while_stmt 285
! #define for_stmt 286
! #define try_stmt 287
! #define except_clause 288
! #define suite 289
! #define test 290
! #define and_test 291
! #define not_test 292
! #define comparison 293
! #define comp_op 294
! #define expr 295
! #define xor_expr 296
! #define and_expr 297
! #define shift_expr 298
! #define arith_expr 299
! #define term 300
! #define factor 301
! #define power 302
! #define atom 303
! #define listmaker 304
! #define lambdef 305
! #define trailer 306
! #define subscriptlist 307
! #define subscript 308
! #define sliceop 309
! #define exprlist 310
! #define testlist 311
! #define dictmaker 312
! #define classdef 313
! #define arglist 314
! #define argument 315
! #define list_iter 316
! #define list_for 317
! #define list_if 318
--- 11,64 ----
#define small_stmt 266
#define expr_stmt 267
! #define augassign 268
! #define print_stmt 269
! #define del_stmt 270
! #define pass_stmt 271
! #define flow_stmt 272
! #define break_stmt 273
! #define continue_stmt 274
! #define return_stmt 275
! #define raise_stmt 276
! #define import_stmt 277
! #define import_as_name 278
! #define dotted_as_name 279
! #define dotted_name 280
! #define global_stmt 281
! #define exec_stmt 282
! #define assert_stmt 283
! #define compound_stmt 284
! #define if_stmt 285
! #define while_stmt 286
! #define for_stmt 287
! #define try_stmt 288
! #define except_clause 289
! #define suite 290
! #define test 291
! #define and_test 292
! #define not_test 293
! #define comparison 294
! #define comp_op 295
! #define expr 296
! #define xor_expr 297
! #define and_expr 298
! #define shift_expr 299
! #define arith_expr 300
! #define term 301
! #define factor 302
! #define power 303
! #define atom 304
! #define listmaker 305
! #define lambdef 306
! #define trailer 307
! #define subscriptlist 308
! #define subscript 309
! #define sliceop 310
! #define exprlist 311
! #define testlist 312
! #define dictmaker 313
! #define classdef 314
! #define arglist 315
! #define argument 316
! #define list_iter 317
! #define list_for 318
! #define list_if 319
Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.63
retrieving revision 2.64
diff -C2 -r2.63 -r2.64
*** object.h 2000/07/16 12:04:30 2.63
--- object.h 2000/08/24 20:09:45 2.64
***************
*** 152,155 ****
--- 152,166 ----
unaryfunc nb_oct;
unaryfunc nb_hex;
+ binaryfunc nb_inplace_add;
+ binaryfunc nb_inplace_subtract;
+ binaryfunc nb_inplace_multiply;
+ binaryfunc nb_inplace_divide;
+ binaryfunc nb_inplace_remainder;
+ ternaryfunc nb_inplace_power;
+ binaryfunc nb_inplace_lshift;
+ binaryfunc nb_inplace_rshift;
+ binaryfunc nb_inplace_and;
+ binaryfunc nb_inplace_xor;
+ binaryfunc nb_inplace_or;
} PyNumberMethods;
***************
*** 163,166 ****
--- 174,179 ----
intintobjargproc sq_ass_slice;
objobjproc sq_contains;
+ binaryfunc sq_inplace_concat;
+ intargfunc sq_inplace_repeat;
} PySequenceMethods;
***************
*** 316,321 ****
#endif
#define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
! Py_TPFLAGS_HAVE_SEQUENCE_IN)
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
--- 329,338 ----
#endif
+ /* PySequenceMethods and PyNumberMethods contain in-place operators */
+ #define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3)
+
#define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
! Py_TPFLAGS_HAVE_SEQUENCE_IN | \
! Py_TPFLAGS_HAVE_INPLACEOPS)
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
Index: opcode.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/opcode.h,v
retrieving revision 2.29
retrieving revision 2.30
diff -C2 -r2.29 -r2.30
*** opcode.h 2000/08/24 00:32:09 2.29
--- opcode.h 2000/08/24 20:09:45 2.30
***************
*** 22,25 ****
--- 22,26 ----
#define ROT_THREE 3
#define DUP_TOP 4
+ #define ROT_FOUR 5
#define UNARY_POSITIVE 10
***************
*** 48,51 ****
--- 49,57 ----
/* Also uses 51-53 */
+ #define INPLACE_ADD 55
+ #define INPLACE_SUBTRACT 56
+ #define INPLACE_MULTIPLY 57
+ #define INPLACE_DIVIDE 58
+ #define INPLACE_MODULO 59
#define STORE_SUBSCR 60
#define DELETE_SUBSCR 61
***************
*** 56,61 ****
#define BINARY_XOR 65
#define BINARY_OR 66
-
#define PRINT_EXPR 70
#define PRINT_ITEM 71
--- 62,67 ----
#define BINARY_XOR 65
#define BINARY_OR 66
+ #define INPLACE_POWER 67
#define PRINT_EXPR 70
#define PRINT_ITEM 71
***************
*** 63,67 ****
#define PRINT_ITEM_TO 73
#define PRINT_NEWLINE_TO 74
!
#define BREAK_LOOP 80
--- 69,77 ----
#define PRINT_ITEM_TO 73
#define PRINT_NEWLINE_TO 74
! #define INPLACE_LSHIFT 75
! #define INPLACE_RSHIFT 76
! #define INPLACE_AND 77
! #define INPLACE_XOR 78
! #define INPLACE_OR 79
#define BREAK_LOOP 80
***************
*** 85,89 ****
#define STORE_GLOBAL 97 /* "" */
#define DELETE_GLOBAL 98 /* "" */
!
#define LOAD_CONST 100 /* Index in const list */
#define LOAD_NAME 101 /* Index in name list */
--- 95,99 ----
#define STORE_GLOBAL 97 /* "" */
#define DELETE_GLOBAL 98 /* "" */
! #define DUP_TOPX 99 /* number of items to duplicate */
#define LOAD_CONST 100 /* Index in const list */
#define LOAD_NAME 101 /* Index in name list */
Index: token.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/token.h,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** token.h 2000/07/09 00:55:06 2.15
--- token.h 2000/08/24 20:09:45 2.16
***************
*** 54,61 ****
#define RIGHTSHIFT 35
#define DOUBLESTAR 36
/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
! #define OP 37
! #define ERRORTOKEN 38
! #define N_TOKENS 39
/* Special definitions for cooperation with parser */
--- 54,72 ----
#define RIGHTSHIFT 35
#define DOUBLESTAR 36
+ #define PLUSEQUAL 37
+ #define MINEQUAL 38
+ #define STAREQUAL 39
+ #define SLASHEQUAL 40
+ #define PERCENTEQUAL 41
+ #define AMPEREQUAL 42
+ #define VBAREQUAL 43
+ #define CIRCUMFLEXEQUAL 44
+ #define LEFTSHIFTEQUAL 45
+ #define RIGHTSHIFTEQUAL 46
+ #define DOUBLESTAREQUAL 47
/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
! #define OP 48
! #define ERRORTOKEN 49
! #define N_TOKENS 50
/* Special definitions for cooperation with parser */