Update of /cvsroot/jython/jython/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv17400
Modified Files:
make_binops.py
Log Message:
Added __floordiv__ and __truediv__ (pep-238).
Index: make_binops.py
===================================================================
RCS file: /cvsroot/jython/jython/Misc/make_binops.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** make_binops.py 2001/02/04 14:51:47 1.4
--- make_binops.py 2002/01/13 18:11:27 1.5
***************
*** 3,6 ****
--- 3,7 ----
binops = \
[('add', '+'), ('sub', '-'), ('mul', '*'), ('div', '/'),
+ ('floordiv', '//'), ('truediv', '/'),
('mod', '%'), ('divmod', 'divmod'), ('pow', '**'),
('lshift', '<<'), ('rshift', '>>'), ('and', '&'), ('or', '|'), ('xor', '^')]
***************
*** 41,45 ****
* with these operands.
**/
! public final PyObject _%(name)s(PyObject o2) {
PyObject x = __%(name)s__(o2);
if (x != null)
--- 42,46 ----
* with these operands.
**/
! public final PyObject _%(name)s(PyObject o2) {%(divhook)s
PyObject x = __%(name)s__(o2);
if (x != null)
***************
*** 60,68 ****
for name, op in binops:
rfunction = function = 'return null;'
if name == 'pow':
function = 'return __pow__(other, null);'
!
! fp.write(template % {'name':name, 'op':op, 'function':function, 'rfunction':rfunction})
fp.write(' // Generated by make_binops.py (End)\n\n')
--- 61,80 ----
for name, op in binops:
rfunction = function = 'return null;'
+ divhook = ""
if name == 'pow':
function = 'return __pow__(other, null);'
! if name == 'div':
! divhook = '''
! if (Options.Qnew)
! return _truediv(o2);'''
!
! fp.write(template % {
! 'name':name,
! 'op':op,
! 'function':function,
! 'rfunction':rfunction,
! 'divhook':divhook
! })
fp.write(' // Generated by make_binops.py (End)\n\n')
|