From: brian z. <bz...@us...> - 2005-03-01 04:06:28
|
Update of /cvsroot/jython/jython/org/python/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5808/org/python/core Modified Files: __builtin__.java PyComplex.java ArgParser.java Log Message: conversion of PyComplex to new-style class; patches #1152994 and #1153003 by johahn Index: __builtin__.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/__builtin__.java,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** __builtin__.java 27 Feb 2005 16:44:12 -0000 2.62 --- __builtin__.java 1 Mar 2005 04:06:03 -0000 2.63 *************** *** 108,123 **** /* newstyle */ ! dict.__setitem__("object",PyType.fromClass(PyObject.class)); ! dict.__setitem__("type",PyType.fromClass(PyType.class)); ! dict.__setitem__("int",PyType.fromClass(PyInteger.class)); ! dict.__setitem__("float",PyType.fromClass(PyFloat.class)); dict.__setitem__("long", PyType.fromClass(PyLong.class)); ! dict.__setitem__("dict",PyType.fromClass(PyDictionary.class)); ! dict.__setitem__("list",PyType.fromClass(PyList.class)); ! dict.__setitem__("property",PyType.fromClass(PyProperty.class)); ! dict.__setitem__("staticmethod",PyType.fromClass(PyStaticMethod.class)); dict.__setitem__("classmethod", PyType.fromClass(PyClassMethod.class)); ! dict.__setitem__("super",PyType.fromClass(PySuper.class)); /* - */ --- 108,124 ---- /* newstyle */ ! dict.__setitem__("object", PyType.fromClass(PyObject.class)); ! dict.__setitem__("type", PyType.fromClass(PyType.class)); ! dict.__setitem__("int", PyType.fromClass(PyInteger.class)); ! dict.__setitem__("float", PyType.fromClass(PyFloat.class)); dict.__setitem__("long", PyType.fromClass(PyLong.class)); ! dict.__setitem__("complex", PyType.fromClass(PyComplex.class)); ! dict.__setitem__("dict", PyType.fromClass(PyDictionary.class)); ! dict.__setitem__("list", PyType.fromClass(PyList.class)); ! dict.__setitem__("property", PyType.fromClass(PyProperty.class)); ! dict.__setitem__("staticmethod", PyType.fromClass(PyStaticMethod.class)); dict.__setitem__("classmethod", PyType.fromClass(PyClassMethod.class)); ! dict.__setitem__("super", PyType.fromClass(PySuper.class)); /* - */ *************** *** 226,244 **** } - public static PyComplex complex(PyObject real, PyObject imag) { - if (real instanceof PyString) - throw Py.TypeError("complex() can't take second arg" + - " if first is a string"); - if (imag instanceof PyString) - throw Py.TypeError("complex() second arg can't be a string"); - return (PyComplex)real.__complex__().__add__( - imag.__complex__().__mul__(PyComplex.J)); - } - - public static PyComplex complex(PyObject real) { - return real.__complex__(); - } - - public static void delattr(PyObject o, PyString n) { o.__delattr__(n); --- 227,230 ---- Index: PyComplex.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyComplex.java,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** PyComplex.java 22 Feb 2005 04:19:30 -0000 2.11 --- PyComplex.java 1 Mar 2005 04:06:18 -0000 2.12 *************** *** 3,7 **** /** ! * A builtin python comples number */ --- 3,7 ---- /** ! * A builtin python complex number */ [...1436 lines suppressed...] *************** *** 417,420 **** --- 1571,1578 ---- public PyComplex conjugate() { + return complex_conjugate(); + } + + final PyComplex complex_conjugate() { return new PyComplex(real, -imag); } *************** *** 422,427 **** public boolean isMappingType() { return false; } public boolean isSequenceType() { return false; } - - - } --- 1580,1582 ---- Index: ArgParser.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/ArgParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ArgParser.java 23 Feb 2005 04:26:21 -0000 1.7 --- ArgParser.java 1 Mar 2005 04:06:18 -0000 1.8 *************** *** 170,174 **** /** ! * Return an optiona argument as a PyObject. * @param pos The position of the argument. First argument is * numbered 0. --- 170,174 ---- /** ! * Return an optional argument as a PyObject. * @param pos The position of the argument. First argument is * numbered 0. *************** *** 198,209 **** private void check() { l1: for (int i = 0; i < kws.length; i++) { for (int j = 0; j < params.length; j++) { ! if (kws[i].equals(params[j])) continue l1; } ! throw Py.TypeError(kws[i] + " is an invalid keyword argument " + ! "for this function"); } } --- 198,215 ---- private void check() { + int nargs = args.length - kws.length; l1: for (int i = 0; i < kws.length; i++) { for (int j = 0; j < params.length; j++) { ! if (kws[i].equals(params[j])) { ! if (j < nargs) { ! throw Py.TypeError("keyword parameter '" + params[j] + ! "' was given by position and by name"); ! } continue l1; + } } ! throw Py.TypeError("'" + kws[i] + "' is an invalid keyword " + ! "argument for this function"); } } |