You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <pj...@us...> - 2008-12-08 19:44:17
|
Revision: 5722 http://jython.svn.sourceforge.net/jython/?rev=5722&view=rev Author: pjenvey Date: 2008-12-08 19:44:12 +0000 (Mon, 08 Dec 2008) Log Message: ----------- use hex idstrs (without any padding) to more closely resemble CPython Modified Paths: -------------- trunk/jython/src/org/python/core/IdImpl.java Modified: trunk/jython/src/org/python/core/IdImpl.java =================================================================== --- trunk/jython/src/org/python/core/IdImpl.java 2008-12-07 18:57:27 UTC (rev 5721) +++ trunk/jython/src/org/python/core/IdImpl.java 2008-12-08 19:44:12 UTC (rev 5722) @@ -72,10 +72,8 @@ } } - // XXX maybe should display both this id and identityHashCode - // XXX preserve the old "at ###" style? public String idstr(PyObject o) { - return Long.toString(id(o)); + return String.format("0x%x", id(o)); } public synchronized long java_obj_id(Object o) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-07 18:57:32
|
Revision: 5721 http://jython.svn.sourceforge.net/jython/?rev=5721&view=rev Author: fwierzbicki Date: 2008-12-07 18:57:27 +0000 (Sun, 07 Dec 2008) Log Message: ----------- A couple more missed adaptations revealed by sympy testing. Modified Paths: -------------- trunk/jython/src/org/python/antlr/adapter/AstAdapters.java Modified: trunk/jython/src/org/python/antlr/adapter/AstAdapters.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/AstAdapters.java 2008-12-07 06:35:04 UTC (rev 5720) +++ trunk/jython/src/org/python/antlr/adapter/AstAdapters.java 2008-12-07 18:57:27 UTC (rev 5721) @@ -103,6 +103,7 @@ return (stmt)stmtAdapter.py2ast(o); } + //XXX: Unnecessary but needs to be fixed in the code generation of asdl_antlr.py public static Object py2string(Object o) { if (o == null || o instanceof PyString) { return o; @@ -187,7 +188,29 @@ } public static PyObject cmpop2py(cmpopType o) { - return cmpopAdapter.ast2py(o); + switch (o) { + case Eq: + return new Eq(); + case NotEq: + return new NotEq(); + case Lt: + return new Lt(); + case LtE: + return new LtE(); + case Gt: + return new Gt(); + case GtE: + return new GtE(); + case Is: + return new Is(); + case IsNot: + return new IsNot(); + case In: + return new In(); + case NotIn: + return new NotIn(); + } + return Py.None; } public static PyObject unaryop2py(unaryopType o) { @@ -263,6 +286,18 @@ if (o == null || o instanceof unaryopType) { return (unaryopType)o; } + if (o instanceof PyObject) { + switch (((PyObject)o).asInt()) { + case 1: + return unaryopType.Invert; + case 2: + return unaryopType.Not; + case 3: + return unaryopType.UAdd; + case 4: + return unaryopType.USub; + } + } //FIXME: investigate the right exception throw Py.TypeError("Can't convert " + o.getClass().getName() + " to unaryop node"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-12-07 06:35:13
|
Revision: 5720 http://jython.svn.sourceforge.net/jython/?rev=5720&view=rev Author: nriley Date: 2008-12-07 06:35:04 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Java 6 javac on x64 Linux requires even more memory to compile Jython Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-07 04:15:26 UTC (rev 5719) +++ trunk/jython/build.xml 2008-12-07 06:35:04 UTC (rev 5720) @@ -459,7 +459,7 @@ debug="${debug}" deprecation="${deprecation}" nowarn="${nowarn}" - memoryMaximumSize="128m" + memoryMaximumSize="192m" fork="true"> <src path="${source.dir}"/> <src path="${gensrc.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-07 04:15:29
|
Revision: 5719 http://jython.svn.sourceforge.net/jython/?rev=5719&view=rev Author: fwierzbicki Date: 2008-12-07 04:15:26 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Fixed bugs in mutable ast revealed by running sympy tests. Modified Paths: -------------- trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java trunk/jython/src/org/python/core/AstList.java Modified: trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2008-12-06 22:50:19 UTC (rev 5718) +++ trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2008-12-07 04:15:26 UTC (rev 5719) @@ -22,12 +22,31 @@ public class CmpopAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; + switch (((PyObject)o).asInt()) { + case 1: + return cmpopType.Eq; + case 2: + return cmpopType.NotEq; + case 3: + return cmpopType.Lt; + case 4: + return cmpopType.LtE; + case 5: + return cmpopType.Gt; + case 6: + return cmpopType.GtE; + case 7: + return cmpopType.Is; + case 8: + return cmpopType.IsNot; + case 9: + return cmpopType.In; + case 10: + return cmpopType.NotIn; } - return o; + //FIXME: investigate the right exception - //throw Py.TypeError("Can't convert " + o.getClass().getName() + " to cmpop node"); + throw Py.TypeError("Can't convert " + o.getClass().getName() + " to cmpop node"); } public PyObject ast2py(Object o) { Modified: trunk/jython/src/org/python/core/AstList.java =================================================================== --- trunk/jython/src/org/python/core/AstList.java 2008-12-06 22:50:19 UTC (rev 5718) +++ trunk/jython/src/org/python/core/AstList.java 2008-12-07 04:15:26 UTC (rev 5719) @@ -430,7 +430,12 @@ @ExposedMethod(defaults = "-1") final PyObject astlist_pop(int n) { - return (PyObject)data.remove(n); + if (adapter == null) { + return (PyObject)data.remove(n); + } + Object element = data.remove(n); + return (PyObject)adapter.ast2py(element); + } protected PyObject repeat(int count) { @@ -584,7 +589,12 @@ } public PyObject pyset(int index, PyObject element) { - return (PyObject)data.set(index, element); + if (adapter == null) { + return (PyObject)data.set(index, element); + } + Object o = adapter.py2ast(element); + data.set(index, o); + return element; } public Object remove(int index) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-12-06 22:50:24
|
Revision: 5718 http://jython.svn.sourceforge.net/jython/?rev=5718&view=rev Author: nriley Date: 2008-12-06 22:50:19 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Java 6 javac on Mac OS X requires more memory to compile Jython Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-06 22:14:43 UTC (rev 5717) +++ trunk/jython/build.xml 2008-12-06 22:50:19 UTC (rev 5718) @@ -459,7 +459,8 @@ debug="${debug}" deprecation="${deprecation}" nowarn="${nowarn}" - fork="yes"> + memoryMaximumSize="128m" + fork="true"> <src path="${source.dir}"/> <src path="${gensrc.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-12-06 22:22:13
|
Revision: 5716 http://jython.svn.sourceforge.net/jython/?rev=5716&view=rev Author: otmarhumbel Date: 2008-12-06 21:44:53 +0000 (Sat, 06 Dec 2008) Log Message: ----------- fork the biggest javac task this hopefully enables hudson's build Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-06 15:00:08 UTC (rev 5715) +++ trunk/jython/build.xml 2008-12-06 21:44:53 UTC (rev 5716) @@ -460,7 +460,8 @@ source="${jdk.source.version}" debug="${debug}" deprecation="${deprecation}" - nowarn="${nowarn}"> + nowarn="${nowarn}" + fork="yes"> <src path="${source.dir}"/> <src path="${gensrc.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-12-06 22:20:10
|
Revision: 5717 http://jython.svn.sourceforge.net/jython/?rev=5717&view=rev Author: otmarhumbel Date: 2008-12-06 22:14:43 +0000 (Sat, 06 Dec 2008) Log Message: ----------- javac ignores the optimize option, according to http://ant.apache.org/manual/ Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-12-06 21:44:53 UTC (rev 5716) +++ trunk/jython/build.xml 2008-12-06 22:14:43 UTC (rev 5717) @@ -58,7 +58,6 @@ #build.compiler=modern #jdk.target.version=1.5 #debug=false -#optimize=off #deprecation=off # - the svn main directory to build from; only needed for full-build @@ -418,7 +417,6 @@ target="${jdk.target.version}" source="${jdk.source.version}" debug="${debug}" - optimize="${optimize}" deprecation="${deprecation}" nowarn="${nowarn}"> <include name="org/python/util/TemplateAntTask.java" /> @@ -476,7 +474,6 @@ target="${jdk.target.version}" source="${jdk.source.version}" debug="${debug}" - optimize="${optimize}" deprecation="${deprecation}" nowarn="${nowarn}"/> @@ -486,7 +483,6 @@ target="${jdk.target.version}" source="${jdk.source.version}" debug="${debug}" - optimize="${optimize}" deprecation="${deprecation}" nowarn="${nowarn}"> <classpath refid="test.classpath" /> @@ -555,7 +551,6 @@ <attribute name="build-compiler" value="${build.compiler}" /> <attribute name="jdk-target-version" value="${jdk.target.version}" /> <attribute name="debug" value="${debug}" /> - <attribute name="optimize" value="${optimize}" /> </section> </manifest> </jar> @@ -588,7 +583,6 @@ <attribute name="build-compiler" value="${build.compiler}" /> <attribute name="jdk-target-version" value="${jdk.target.version}" /> <attribute name="debug" value="${debug}" /> - <attribute name="optimize" value="${optimize}" /> </section> </manifest> </jar> @@ -718,7 +712,6 @@ target="${jdk.target.version}" source="${jdk.source.version}" debug="${debug}" - optimize="${optimize}" deprecation="${deprecation}" nowarn="${nowarn}" /> @@ -757,7 +750,6 @@ <attribute name="build-compiler" value="${build.compiler}" /> <attribute name="jdk-target-version" value="${jdk.target.version}" /> <attribute name="debug" value="${debug}" /> - <attribute name="optimize" value="${optimize}" /> </section> </manifest> </jar> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-06 15:00:13
|
Revision: 5715 http://jython.svn.sourceforge.net/jython/?rev=5715&view=rev Author: fwierzbicki Date: 2008-12-06 15:00:08 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Now able to use the exact copy of CPython's ast.py Copied from: http://svn.python.org/projects/python/branches/release26-maint/Lib/ast.py Modified Paths: -------------- trunk/jython/Lib/ast.py Modified: trunk/jython/Lib/ast.py =================================================================== --- trunk/jython/Lib/ast.py 2008-12-06 09:02:53 UTC (rev 5714) +++ trunk/jython/Lib/ast.py 2008-12-06 15:00:08 UTC (rev 5715) @@ -25,10 +25,10 @@ :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. """ -import sys from _ast import * from _ast import __version__ + def parse(expr, filename='<unknown>', mode='exec'): """ Parse an expression into an AST node. @@ -90,7 +90,7 @@ rv += ', '.join('%s=%s' % (a, _format(getattr(node, a))) for a in node._attributes) return rv + ')' - elif hasattr(node, "__iter__"): + elif isinstance(node, list): return '[%s]' % ', '.join(_format(x) for x in node) return repr(node) if not isinstance(node, AST): @@ -168,7 +168,7 @@ for name, field in iter_fields(node): if isinstance(field, AST): yield field - elif hasattr(field, "__iter__"): + elif isinstance(field, list): for item in field: if isinstance(item, AST): yield item @@ -233,7 +233,7 @@ def generic_visit(self, node): """Called if no explicit visitor function exists for a node.""" for field, value in iter_fields(node): - if hasattr(value, "__iter__"): + if isinstance(value, list): for item in value: if isinstance(item, AST): self.visit(item) @@ -280,7 +280,7 @@ def generic_visit(self, node): for field, old_value in iter_fields(node): old_value = getattr(node, field, None) - if hasattr(old_value, "__iter__"): + if isinstance(old_value, list): new_values = [] for value in old_value: if isinstance(value, AST): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-06 09:02:57
|
Revision: 5714 http://jython.svn.sourceforge.net/jython/?rev=5714&view=rev Author: pjenvey Date: 2008-12-06 09:02:53 +0000 (Sat, 06 Dec 2008) Log Message: ----------- revert the astlist workaround as it subclasses list now Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2008-12-06 06:55:48 UTC (rev 5713) +++ trunk/jython/Lib/test/test_ast.py 2008-12-06 09:02:53 UTC (rev 5714) @@ -5,7 +5,7 @@ def to_tuple(t): if t is None or isinstance(t, (basestring, int, long, complex)): return t - elif hasattr(t, "__iter__"): + elif isinstance(t, list): return [to_tuple(e) for e in t] result = [t.__class__.__name__] if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): @@ -131,7 +131,7 @@ parent_pos = (ast_node.lineno, ast_node.col_offset) for name in ast_node._fields: value = getattr(ast_node, name) - if hasattr(value, "__iter__"): + if isinstance(value, list): for child in value: self._assert_order(child, parent_pos) elif value is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-06 06:55:52
|
Revision: 5713 http://jython.svn.sourceforge.net/jython/?rev=5713&view=rev Author: pjenvey Date: 2008-12-06 06:55:48 +0000 (Sat, 06 Dec 2008) Log Message: ----------- correct mismatch between partition/rpartition and their exposed versions Modified Paths: -------------- trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2008-12-06 06:52:28 UTC (rev 5712) +++ trunk/jython/src/org/python/core/PyUnicode.java 2008-12-06 06:55:48 UTC (rev 5713) @@ -633,6 +633,10 @@ new ReversedIterator(newSubsequenceIterator())))); } + public PyTuple partition(PyObject sep) { + return unicode_partition(sep); + } + @ExposedMethod final PyTuple unicode_partition(PyObject sep) { return unicodePartition(sep); @@ -869,6 +873,10 @@ } } + public PyTuple rpartition(PyObject sep) { + return unicode_rpartition(sep); + } + @ExposedMethod final PyTuple unicode_rpartition(PyObject sep) { return unicodeRpartition(sep); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-12-06 06:52:33
|
Revision: 5712 http://jython.svn.sourceforge.net/jython/?rev=5712&view=rev Author: pjenvey Date: 2008-12-06 06:52:28 +0000 (Sat, 06 Dec 2008) Log Message: ----------- o fix str/unicode add/join to decode when appropriate o fix '%r' % u'' returning unicode o cast fastSequence to a PySequence Modified Paths: -------------- trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/src/org/python/core/PySequence.java trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2008-12-06 05:18:08 UTC (rev 5711) +++ trunk/jython/Lib/test/test_unicode_jy.py 2008-12-06 06:52:28 UTC (rev 5712) @@ -72,7 +72,18 @@ self.assertEqual(u'%c' % sys.maxunicode, u'\U0010ffff') self.assertRaises(OverflowError, '%c'.__mod__, sys.maxunicode + 1) + def test_repr(self): + self.assert_(isinstance('%r' % u'foo', str)) + def test_concat(self): + self.assertRaises(UnicodeDecodeError, lambda : u'' + '毛泽东') + self.assertRaises(UnicodeDecodeError, lambda : '毛泽东' + u'') + + def test_join(self): + self.assertRaises(UnicodeDecodeError, u''.join, ['foo', '毛泽东']) + self.assertRaises(UnicodeDecodeError, '毛泽东'.join, [u'foo', u'bar']) + + def test_main(): test_support.run_unittest(UnicodeTestCase) Modified: trunk/jython/src/org/python/core/PySequence.java =================================================================== --- trunk/jython/src/org/python/core/PySequence.java 2008-12-06 05:18:08 UTC (rev 5711) +++ trunk/jython/src/org/python/core/PySequence.java 2008-12-06 06:52:28 UTC (rev 5712) @@ -218,9 +218,9 @@ // Return a copy of a sequence where the __len__() method is // telling the truth. - protected static PyObject fastSequence(PyObject seq, String msg) { - if(seq instanceof PySequence) { - return seq; + protected static PySequence fastSequence(PyObject seq, String msg) { + if (seq instanceof PySequence) { + return (PySequence)seq; } PyList list = new PyList(); PyObject iter = Py.iter(seq, msg); Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-12-06 05:18:08 UTC (rev 5711) +++ trunk/jython/src/org/python/core/PyString.java 2008-12-06 06:52:28 UTC (rev 5712) @@ -704,21 +704,20 @@ return repeat(o.asIndex(Py.OverflowError)); } - public PyObject __add__(PyObject generic_other) { - return str___add__(generic_other); + public PyObject __add__(PyObject other) { + return str___add__(other); } @ExposedMethod(type = MethodType.BINARY) - final PyObject str___add__(PyObject generic_other) { - if (generic_other instanceof PyString) { - PyString other = (PyString)generic_other; - String result = string.concat(other.string); - if (generic_other instanceof PyUnicode) { - return new PyUnicode(result); - } - return createInstance(result); + final PyObject str___add__(PyObject other) { + if (other instanceof PyUnicode) { + return decode().__add__(other); } - else return null; + if (other instanceof PyString) { + PyString otherStr = (PyString)other; + return new PyString(string.concat(otherStr.string)); + } + return null; } @ExposedMethod @@ -1847,67 +1846,135 @@ } } - return newPiece.str_join(splitfields(oldPiece.string, maxsplit)); + return newPiece.join(splitfields(oldPiece.string, maxsplit)); } - public String join(PyObject seq) { - return str_join(seq).string; + public PyString join(PyObject seq) { + return str_join(seq); } @ExposedMethod final PyString str_join(PyObject obj) { - // Similar to CPython's abstract::PySequence_Fast - PySequence seq; - if (obj instanceof PySequence) { - seq = (PySequence)obj; - } else { - seq = new PyList(obj.__iter__()); + PySequence seq = fastSequence(obj, ""); + int seqLen = seq.__len__(); + if (seqLen == 0) { + return Py.EmptyString; } PyObject item; - int seqlen = seq.__len__(); - if (seqlen == 0) { - return createInstance("", true); - } - if (seqlen == 1) { + if (seqLen == 1) { item = seq.pyget(0); - if (item.getType() == PyUnicode.TYPE || - (item.getType() == PyString.TYPE && getType() == PyString.TYPE)) { + if (item.getType() == PyString.TYPE || item.getType() == PyUnicode.TYPE) { return (PyString)item; } } - boolean needsUnicode = false; - long joinedSize = 0; - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < seqlen; i++) { + // There are at least two things to join, or else we have a subclass of the + // builtin types in the sequence. Do a pre-pass to figure out the total amount of + // space we'll need, see whether any argument is absurd, and defer to the Unicode + // join if appropriate + int i = 0; + long size = 0; + int sepLen = string.length(); + for (; i < seqLen; i++) { item = seq.pyget(i); if (!(item instanceof PyString)) { throw Py.TypeError(String.format("sequence item %d: expected string, %.80s found", i, item.getType().fastGetName())); } if (item instanceof PyUnicode) { - needsUnicode = true; + // Defer to Unicode join. CAUTION: There's no gurantee that the original + // sequence can be iterated over again, so we must pass seq here + return unicodeJoin(seq); } - if (i > 0) { - buf.append(string); - joinedSize += string.length(); + + if (i != 0) { + size += sepLen; } - String itemString = ((PyString)item).string; - buf.append(itemString); - joinedSize += itemString.length(); - if (joinedSize > Integer.MAX_VALUE) { + size += ((PyString)item).string.length(); + if (size > Integer.MAX_VALUE) { throw Py.OverflowError("join() result is too long for a Python string"); } } - if (needsUnicode){ - return new PyUnicode(buf.toString()); + // Catenate everything + StringBuilder buf = new StringBuilder((int)size); + for (i = 0; i < seqLen; i++) { + item = seq.pyget(i); + if (i != 0) { + buf.append(string); + } + buf.append(((PyString)item).string); } - return createInstance(buf.toString(), true); + return new PyString(buf.toString()); } + final PyUnicode unicodeJoin(PyObject obj) { + PySequence seq = fastSequence(obj, ""); + // A codec may be invoked to convert str objects to Unicode, and so it's possible + // to call back into Python code during PyUnicode_FromObject(), and so it's + // possible for a sick codec to change the size of fseq (if seq is a list). + // Therefore we have to keep refetching the size -- can't assume seqlen is + // invariant. + int seqLen = seq.__len__(); + // If empty sequence, return u"" + if (seqLen == 0) { + return new PyUnicode(); + } + // If singleton sequence with an exact Unicode, return that + PyObject item; + if (seqLen == 1) { + item = seq.pyget(0); + if (item.getType() == PyUnicode.TYPE) { + return (PyUnicode)item; + } + } + + String sep = null; + if (seqLen > 1) { + if (this instanceof PyUnicode) { + sep = string; + } else { + sep = ((PyUnicode)decode()).string; + // In case decode()'s codec mutated seq + seqLen = seq.__len__(); + } + } + + // At least two items to join, or one that isn't exact Unicode + long size = 0; + int sepLen = string.length(); + StringBuilder buf = new StringBuilder(); + String itemString; + for (int i = 0; i < seqLen; i++) { + item = seq.pyget(i); + // Convert item to Unicode + if (!(item instanceof PyString)) { + throw Py.TypeError(String.format("sequence item %d: expected string or Unicode," + + " %.80s found", + i, item.getType().fastGetName())); + } + if (!(item instanceof PyUnicode)) { + item = ((PyString)item).decode(); + // In case decode()'s codec mutated seq + seqLen = seq.__len__(); + } + itemString = ((PyUnicode)item).string; + + if (i != 0) { + size += sepLen; + buf.append(sep); + } + size += itemString.length(); + if (size > Integer.MAX_VALUE) { + throw Py.OverflowError("join() result is too long for a Python string"); + } + buf.append(itemString); + } + return new PyUnicode(buf.toString()); + } + public boolean startswith(PyObject prefix) { return str_startswith(prefix, 0, null); } @@ -2826,11 +2893,11 @@ fill = ' '; switch(c) { case 's': - case 'r': - fill = ' '; if (arg instanceof PyUnicode) { needUnicode = true; } + case 'r': + fill = ' '; if (c == 's') if (needUnicode) string = arg.__unicode__().toString(); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2008-12-06 05:18:08 UTC (rev 5711) +++ trunk/jython/src/org/python/core/PyUnicode.java 2008-12-06 06:52:28 UTC (rev 5712) @@ -455,9 +455,21 @@ return str___rmul__(o); } + public PyObject __add__(PyObject other) { + return unicode___add__(other); + } + @ExposedMethod(type = MethodType.BINARY) - final PyObject unicode___add__(PyObject generic_other) { - return str___add__(generic_other); + final PyObject unicode___add__(PyObject other) { + PyUnicode otherUnicode; + if (other instanceof PyUnicode) { + otherUnicode = (PyUnicode)other; + } else if (other instanceof PyString) { + otherUnicode = (PyUnicode)((PyString)other).decode(); + } else { + return null; + } + return new PyUnicode(string.concat(otherUnicode.string)); } @ExposedMethod @@ -1098,9 +1110,13 @@ } // end utf-16 aware + public PyString join(PyObject seq) { + return unicode_join(seq); + } + @ExposedMethod - final PyString unicode_join(PyObject seq) { - return str_join(seq); + final PyUnicode unicode_join(PyObject seq) { + return unicodeJoin(seq); } @ExposedMethod(defaults = {"0", "null"}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 05:18:11
|
Revision: 5711 http://jython.svn.sourceforge.net/jython/?rev=5711&view=rev Author: cgroves Date: 2008-12-06 05:18:08 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Identify Java exceptions as exceptions Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/PyException.java Modified: branches/newstyle-java-types/src/org/python/core/PyException.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyException.java 2008-12-06 04:23:45 UTC (rev 5710) +++ branches/newstyle-java-types/src/org/python/core/PyException.java 2008-12-06 05:18:08 UTC (rev 5711) @@ -199,8 +199,17 @@ * @return true if an exception */ public static boolean isExceptionClass(PyObject obj) { - return obj instanceof PyClass - || (obj instanceof PyType && ((PyType)obj).isSubType((PyType)Py.BaseException)); + if (obj instanceof PyClass) { + return true; + } + if (!(obj instanceof PyType)) { + return false; + } + PyType type = ((PyType)obj); + if(type.isSubType((PyType)Py.BaseException)){ + return true; + } + return type.getProxyType() != null && Throwable.class.isAssignableFrom(type.getProxyType()); } /** @@ -210,7 +219,8 @@ * @return true if an exception instance */ public static boolean isExceptionInstance(PyObject obj) { - return obj instanceof PyInstance || obj instanceof PyBaseException; + return obj instanceof PyInstance || obj instanceof PyBaseException + || obj.getJavaProxy() instanceof Throwable; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 04:23:49
|
Revision: 5710 http://jython.svn.sourceforge.net/jython/?rev=5710&view=rev Author: cgroves Date: 2008-12-06 04:23:45 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Fix deserializing Jython objects while not in Python code. __builtin__.__import__ was changed to bail if Py.getFrame was null, but it can be called from Java code as in PyObjectInputStream, so it should just use PySystemState.builtins if it doesn't have a set of builtins from the frame. Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/__builtin__.java Added Paths: ----------- branches/newstyle-java-types/tests/java/org/python/tests/SerializationTest.java Modified: branches/newstyle-java-types/src/org/python/core/__builtin__.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/__builtin__.java 2008-12-06 04:19:46 UTC (rev 5709) +++ branches/newstyle-java-types/src/org/python/core/__builtin__.java 2008-12-06 04:23:45 UTC (rev 5710) @@ -1221,11 +1221,10 @@ public static PyObject __import__(String name, PyObject globals, PyObject locals, PyObject fromlist, int level) { PyFrame frame = Py.getFrame(); - if (frame == null) { - return null; - } - PyObject builtins = frame.f_builtins; - if (builtins == null) { + PyObject builtins; + if (frame != null && frame.f_builtins != null) { + builtins = frame.f_builtins; + } else { builtins = PySystemState.builtins; } Added: branches/newstyle-java-types/tests/java/org/python/tests/SerializationTest.java =================================================================== --- branches/newstyle-java-types/tests/java/org/python/tests/SerializationTest.java (rev 0) +++ branches/newstyle-java-types/tests/java/org/python/tests/SerializationTest.java 2008-12-06 04:23:45 UTC (rev 5710) @@ -0,0 +1,37 @@ +package org.python.tests; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +import junit.framework.TestCase; + +import org.python.core.PyStringMap; +import org.python.core.PySystemState; +import org.python.util.PythonInterpreter; +import org.python.util.PythonObjectInputStream; + +public class SerializationTest extends TestCase { + + private PythonInterpreter interp; + + @Override + protected void setUp() throws Exception { + interp = new PythonInterpreter(new PyStringMap(), new PySystemState()); + interp.exec("from java.io import Serializable"); + interp.exec("class Test(Serializable): pass"); + interp.exec("x = Test()"); + } + + public void testDirect() throws IOException, ClassNotFoundException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + new ObjectOutputStream(os).writeObject(interp.get("x")); + new PythonObjectInputStream(new ByteArrayInputStream(os.toByteArray())).readObject(); + } + + public void testJython() { + interp.set("t", this); + interp.exec("t.testDirect()"); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 04:19:50
|
Revision: 5709 http://jython.svn.sourceforge.net/jython/?rev=5709&view=rev Author: cgroves Date: 2008-12-06 04:19:46 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Add a target to run a single junit test from the tests directory. ant -Dtest=InterpreterTest singlejavatest will run just org.python.util.InterpreterTest and report to the console. Modified Paths: -------------- branches/newstyle-java-types/build.xml Modified: branches/newstyle-java-types/build.xml =================================================================== --- branches/newstyle-java-types/build.xml 2008-12-06 03:23:28 UTC (rev 5708) +++ branches/newstyle-java-types/build.xml 2008-12-06 04:19:46 UTC (rev 5709) @@ -763,6 +763,16 @@ </target> <target name="test" depends="prepare-test,javatest,launchertest,regrtest"/> + <target name="singlejavatest" depends="compile,expose"> + <junit haltonfailure="true" fork="true"> + <formatter type="brief" usefile="false"/> + <sysproperty key="python.cachedir.skip" value="true"/> + <classpath refid="test.classpath"/> + <batchtest> + <fileset dir="${test.source.dir}" includes="**/${test}.java"/> + </batchtest> + </junit> + </target> <target name="prepare-test" depends="init"> <!-- Clean any old test output --> <delete dir="${junit.reports}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 03:23:38
|
Revision: 5708 http://jython.svn.sourceforge.net/jython/?rev=5708&view=rev Author: cgroves Date: 2008-12-06 03:23:28 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Pull the proxy class directly out of the type. Fixes test_jser2 Modified Paths: -------------- branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java Modified: branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java =================================================================== --- branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 03:01:16 UTC (rev 5707) +++ branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 03:23:28 UTC (rev 5708) @@ -9,6 +9,7 @@ import org.python.core.Py; import org.python.core.PyObject; import org.python.core.PyTuple; +import org.python.core.PyType; import org.python.core.__builtin__; public class PythonObjectInputStream extends ObjectInputStream { @@ -29,11 +30,8 @@ String mod = clsName.substring(0, idx); clsName = clsName.substring(idx + 1); PyObject module = importModule(mod); - PyObject pycls = module.__getattr__(clsName.intern()); - Object cls = pycls.__tojava__(Class.class); - if (cls != null && cls != Py.NoConversion) { - return (Class<?>)cls; - } + PyType pycls = (PyType)module.__getattr__(clsName.intern()); + return pycls.getProxyType(); } } try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 03:01:21
|
Revision: 5707 http://jython.svn.sourceforge.net/jython/?rev=5707&view=rev Author: cgroves Date: 2008-12-06 03:01:16 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Tidying Modified Paths: -------------- branches/newstyle-java-types/Lib/test/jser2_classes.py branches/newstyle-java-types/Lib/test/test_jser2.py branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java Property Changed: ---------------- branches/newstyle-java-types/Lib/test/jser2_classes.py branches/newstyle-java-types/Lib/test/test_jser2.py Modified: branches/newstyle-java-types/Lib/test/jser2_classes.py =================================================================== (Binary files differ) Property changes on: branches/newstyle-java-types/Lib/test/jser2_classes.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: branches/newstyle-java-types/Lib/test/test_jser2.py =================================================================== (Binary files differ) Property changes on: branches/newstyle-java-types/Lib/test/test_jser2.py ___________________________________________________________________ Deleted: svn:mime-type - application/octet-stream Modified: branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java =================================================================== --- branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 02:49:45 UTC (rev 5706) +++ branches/newstyle-java-types/src/org/python/util/PythonObjectInputStream.java 2008-12-06 03:01:16 UTC (rev 5707) @@ -1,52 +1,53 @@ // Copyright 2000 Finn Bock - package org.python.util; -import java.io.*; -import org.python.core.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyTuple; +import org.python.core.__builtin__; + public class PythonObjectInputStream extends ObjectInputStream { + public PythonObjectInputStream(InputStream istr) throws IOException { super(istr); } - protected Class resolveClass(ObjectStreamClass v) - throws IOException, ClassNotFoundException { + protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String clsName = v.getName(); - //System.out.println(clsName); if (clsName.startsWith("org.python.proxies")) { int idx = clsName.lastIndexOf('$'); - if (idx > 19) - clsName = clsName.substring(19, idx); - //System.out.println("new:" + clsName); - + if (idx > 19) { + clsName = clsName.substring(19, idx); + } idx = clsName.indexOf('$'); if (idx >= 0) { String mod = clsName.substring(0, idx); - clsName = clsName.substring(idx+1); - + clsName = clsName.substring(idx + 1); PyObject module = importModule(mod); PyObject pycls = module.__getattr__(clsName.intern()); Object cls = pycls.__tojava__(Class.class); - - if (cls != null && cls != Py.NoConversion) - return (Class) cls; + if (cls != null && cls != Py.NoConversion) { + return (Class<?>)cls; + } } } try { return super.resolveClass(v); } catch (ClassNotFoundException exc) { PyObject m = importModule(clsName); - //System.out.println("m:" + m); Object cls = m.__tojava__(Class.class); - //System.out.println("cls:" + cls); - if (cls != null && cls != Py.NoConversion) - return (Class) cls; + if (cls != null && cls != Py.NoConversion) { + return (Class<?>)cls; + } throw exc; } } - private static PyObject importModule(String name) { PyObject fromlist = new PyTuple(Py.newString("__doc__")); return __builtin__.__import__(name, null, null, fromlist); Modified: branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java =================================================================== --- branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java 2008-12-06 02:49:45 UTC (rev 5706) +++ branches/newstyle-java-types/tests/java/org/python/util/InterpreterTest.java 2008-12-06 03:01:16 UTC (rev 5707) @@ -2,8 +2,9 @@ import junit.framework.TestCase; -import org.python.core.*; -import org.python.util.*; +import org.python.core.PyDictionary; +import org.python.core.PyObject; +import org.python.core.PyUnicode; public class InterpreterTest extends TestCase { @@ -13,8 +14,7 @@ public void testBasicEval() throws Exception { PyDictionary test = new PyDictionary(); test.__setitem__(new PyUnicode("one"), new PyUnicode("two")); - PythonInterpreter.initialize(System.getProperties(), null, new -String[] {}); + PythonInterpreter.initialize(System.getProperties(), null, new String[] {}); PythonInterpreter interp = new PythonInterpreter(); PyObject pyo = interp.eval("{u'one': u'two'}"); assertEquals(test, pyo); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-06 02:49:56
|
Revision: 5706 http://jython.svn.sourceforge.net/jython/?rev=5706&view=rev Author: fwierzbicki Date: 2008-12-06 02:49:45 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Added better lineno and col_offset support to a couple of ast nodes, also finished slice support in AstList. Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/ast/Break.java trunk/jython/src/org/python/antlr/ast/Continue.java trunk/jython/src/org/python/antlr/ast/Ellipsis.java trunk/jython/src/org/python/antlr/ast/Pass.java trunk/jython/src/org/python/core/AstList.java Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/ast/asdl_antlr.py 2008-12-06 02:49:45 UTC (rev 5706) @@ -470,45 +470,47 @@ self.emit("public %s() {" % (clsname), depth) self.emit("this(TYPE);", depth + 1) self.emit("}", depth) - fnames = ['"%s"' % f.name for f in fields] - if str(name) in ('stmt', 'expr', 'excepthandler'): - fnames.extend(['"lineno"', '"col_offset"']) - fpargs = ", ".join(fnames) - self.emit("@ExposedNew", depth) - self.emit("@ExposedMethod", depth) - self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % clsname, depth) - self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % clsname, depth + 1) - self.emit('{%s}, %s);' % (fpargs, len(fields)), depth + 2) - i = 0 - for f in fields: - self.emit("set%s(ap.getPyObject(%s));" % (str(f.name).capitalize(), - str(i)), depth+1) - i += 1 - if str(name) in ('stmt', 'expr', 'excepthandler'): - self.emit("int lin = ap.getInt(%s, -1);" % str(i), depth + 1) - self.emit("if (lin != -1) {", depth + 1) - self.emit("setLineno(lin);", depth + 2) - self.emit("}", depth + 1) - self.emit("", 0) + else: + fnames = [] - self.emit("int col = ap.getInt(%s, -1);" % str(i+1), depth + 1) - self.emit("if (col != -1) {", depth + 1) - self.emit("setLineno(col);", depth + 2) - self.emit("}", depth + 1) - self.emit("", 0) - - self.emit("}", depth) + if str(name) in ('stmt', 'expr', 'excepthandler'): + fnames.extend(['"lineno"', '"col_offset"']) + fpargs = ", ".join(fnames) + self.emit("@ExposedNew", depth) + self.emit("@ExposedMethod", depth) + self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % clsname, depth) + self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % clsname, depth + 1) + self.emit('{%s}, %s);' % (fpargs, len(fields)), depth + 2) + i = 0 + for f in fields: + self.emit("set%s(ap.getPyObject(%s));" % (str(f.name).capitalize(), + str(i)), depth+1) + i += 1 + if str(name) in ('stmt', 'expr', 'excepthandler'): + self.emit("int lin = ap.getInt(%s, -1);" % str(i), depth + 1) + self.emit("if (lin != -1) {", depth + 1) + self.emit("setLineno(lin);", depth + 2) + self.emit("}", depth + 1) self.emit("", 0) - fpargs = ", ".join(["PyObject %s" % f.name for f in fields]) - self.emit("public %s(%s) {" % (clsname, fpargs), depth) - for f in fields: - self.emit("set%s(%s);" % (str(f.name).capitalize(), - f.name), depth+1) - self.emit("}", depth) + self.emit("int col = ap.getInt(%s, -1);" % str(i+1), depth + 1) + self.emit("if (col != -1) {", depth + 1) + self.emit("setLineno(col);", depth + 2) + self.emit("}", depth + 1) self.emit("", 0) + self.emit("}", depth) + self.emit("", 0) + + fpargs = ", ".join(["PyObject %s" % f.name for f in fields]) + self.emit("public %s(%s) {" % (clsname, fpargs), depth) + for f in fields: + self.emit("set%s(%s);" % (str(f.name).capitalize(), + f.name), depth+1) + self.emit("}", depth) + self.emit("", 0) + token = asdl.Field('Token', 'token') token.typedef = False fpargs = ", ".join([self.fieldDef(f) for f in [token] + fields]) Modified: trunk/jython/src/org/python/antlr/ast/Break.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Break.java 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/src/org/python/antlr/ast/Break.java 2008-12-06 02:49:45 UTC (rev 5706) @@ -41,6 +41,26 @@ public Break(PyType subType) { super(subType); } + @ExposedNew + @ExposedMethod + public void Break___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Break", args, keywords, new String[] + {"lineno", "col_offset"}, 0); + int lin = ap.getInt(0, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(1, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Break() { + } + public Break(Token token) { super(token); } Modified: trunk/jython/src/org/python/antlr/ast/Continue.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Continue.java 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/src/org/python/antlr/ast/Continue.java 2008-12-06 02:49:45 UTC (rev 5706) @@ -41,6 +41,26 @@ public Continue(PyType subType) { super(subType); } + @ExposedNew + @ExposedMethod + public void Continue___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Continue", args, keywords, new String[] + {"lineno", "col_offset"}, 0); + int lin = ap.getInt(0, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(1, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Continue() { + } + public Continue(Token token) { super(token); } Modified: trunk/jython/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2008-12-06 02:49:45 UTC (rev 5706) @@ -40,6 +40,16 @@ public Ellipsis(PyType subType) { super(subType); } + @ExposedNew + @ExposedMethod + public void Ellipsis___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Ellipsis", args, keywords, new String[] + {}, 0); + } + + public Ellipsis() { + } + public Ellipsis(Token token) { super(token); } Modified: trunk/jython/src/org/python/antlr/ast/Pass.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Pass.java 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/src/org/python/antlr/ast/Pass.java 2008-12-06 02:49:45 UTC (rev 5706) @@ -41,6 +41,26 @@ public Pass(PyType subType) { super(subType); } + @ExposedNew + @ExposedMethod + public void Pass___init__(PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("Pass", args, keywords, new String[] + {"lineno", "col_offset"}, 0); + int lin = ap.getInt(0, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(1, -1); + if (col != -1) { + setLineno(col); + } + + } + + public Pass() { + } + public Pass(Token token) { super(token); } Modified: trunk/jython/src/org/python/core/AstList.java =================================================================== --- trunk/jython/src/org/python/core/AstList.java 2008-12-06 02:35:31 UTC (rev 5705) +++ trunk/jython/src/org/python/core/AstList.java 2008-12-06 02:49:45 UTC (rev 5706) @@ -455,9 +455,62 @@ } protected void setslice(int start, int stop, int step, PyObject value) { - //FIXME + if(stop < start) { + stop = start; + } + if (value instanceof PySequence) { + PySequence sequence = (PySequence) value; + setslicePySequence(start, stop, step, sequence); + } else if (value instanceof List) { + List list = (List)value.__tojava__(List.class); + if(list != null && list != Py.NoConversion) { + setsliceList(start, stop, step, list); + } + } else { + setsliceIterable(start, stop, step, value); + } } - + + protected void setslicePySequence(int start, int stop, int step, PySequence value) { + if (step != 0) { + if(value == this) { + PyList newseq = new PyList(); + PyObject iter = value.__iter__(); + for(PyObject item = null; (item = iter.__iternext__()) != null;) { + newseq.append(item); + } + value = newseq; + } + int n = value.__len__(); + for (int i = 0, j = start; i < n; i++, j += step) { + pyset(j, value.pyget(i)); + } + } + } + + protected void setsliceList(int start, int stop, int step, List value) { + if(step != 1) { + throw Py.TypeError("setslice with java.util.List and step != 1 not supported yet"); + } + int n = value.size(); + for(int i = 0; i < n; i++) { + data.add(i + start, value.get(i)); + } + } + + protected void setsliceIterable(int start, int stop, int step, PyObject value) { + PyObject[] seq; + try { + seq = Py.make_array(value); + } catch (PyException pye) { + if (Py.matchException(pye, Py.TypeError)) { + throw Py.TypeError("can only assign an iterable"); + } + throw pye; + } + setslicePySequence(start, stop, step, new PyList(seq)); + } + public void add(int index, Object element) { data.add(index, element); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-06 02:35:36
|
Revision: 5705 http://jython.svn.sourceforge.net/jython/?rev=5705&view=rev Author: cgroves Date: 2008-12-06 02:35:31 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Needs to be serializable for PySequence to be serializable Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/SequenceIndexDelegate.java Modified: branches/newstyle-java-types/src/org/python/core/SequenceIndexDelegate.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/SequenceIndexDelegate.java 2008-12-05 18:43:33 UTC (rev 5704) +++ branches/newstyle-java-types/src/org/python/core/SequenceIndexDelegate.java 2008-12-06 02:35:31 UTC (rev 5705) @@ -1,9 +1,11 @@ package org.python.core; +import java.io.Serializable; + /** * Handles all the index checking and manipulation for get, set and del operations on a sequence. */ -public abstract class SequenceIndexDelegate { +public abstract class SequenceIndexDelegate implements Serializable { public abstract int len(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-12-05 18:43:44
|
Revision: 5704 http://jython.svn.sourceforge.net/jython/?rev=5704&view=rev Author: nriley Date: 2008-12-05 18:43:33 +0000 (Fri, 05 Dec 2008) Log Message: ----------- avoid test_asynchat on Solaris (everywhere but Linux?); refs #1064 Modified Paths: -------------- trunk/jython/Lib/test/test_asynchat.py Modified: trunk/jython/Lib/test/test_asynchat.py =================================================================== --- trunk/jython/Lib/test/test_asynchat.py 2008-12-05 16:10:15 UTC (rev 5703) +++ trunk/jython/Lib/test/test_asynchat.py 2008-12-05 18:43:33 UTC (rev 5704) @@ -7,8 +7,9 @@ import platform os_name = platform.java_ver()[3][0] -if os_name == 'Mac OS X' or 'BSD' in os_name or 'Windows' in os_name: - raise test_support.TestSkipped('test_asynchat deadlocks on Jython/BSD: ' +if os_name == 'Mac OS X' or os_name == 'SunOS' or 'BSD' in os_name \ + or 'Windows' in os_name: + raise test_support.TestSkipped('test_asynchat deadlocks on Jython: ' 'http://bugs.jython.org/issue1064') HOST = "127.0.0.1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-05 16:10:23
|
Revision: 5703 http://jython.svn.sourceforge.net/jython/?rev=5703&view=rev Author: fwierzbicki Date: 2008-12-05 16:10:15 +0000 (Fri, 05 Dec 2008) Log Message: ----------- org/python/antlr/op/* Derived classes, and fixed lineno, col_offset from ast_antlr.py Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/ast/Assert.java trunk/jython/src/org/python/antlr/ast/Assign.java trunk/jython/src/org/python/antlr/ast/Attribute.java trunk/jython/src/org/python/antlr/ast/AugAssign.java trunk/jython/src/org/python/antlr/ast/BinOp.java trunk/jython/src/org/python/antlr/ast/BoolOp.java trunk/jython/src/org/python/antlr/ast/Call.java trunk/jython/src/org/python/antlr/ast/ClassDef.java trunk/jython/src/org/python/antlr/ast/Compare.java trunk/jython/src/org/python/antlr/ast/Delete.java trunk/jython/src/org/python/antlr/ast/Dict.java trunk/jython/src/org/python/antlr/ast/ExceptHandler.java trunk/jython/src/org/python/antlr/ast/Exec.java trunk/jython/src/org/python/antlr/ast/Expr.java trunk/jython/src/org/python/antlr/ast/For.java trunk/jython/src/org/python/antlr/ast/FunctionDef.java trunk/jython/src/org/python/antlr/ast/GeneratorExp.java trunk/jython/src/org/python/antlr/ast/Global.java trunk/jython/src/org/python/antlr/ast/If.java trunk/jython/src/org/python/antlr/ast/IfExp.java trunk/jython/src/org/python/antlr/ast/Import.java trunk/jython/src/org/python/antlr/ast/ImportFrom.java trunk/jython/src/org/python/antlr/ast/Lambda.java trunk/jython/src/org/python/antlr/ast/List.java trunk/jython/src/org/python/antlr/ast/ListComp.java trunk/jython/src/org/python/antlr/ast/Name.java trunk/jython/src/org/python/antlr/ast/Num.java trunk/jython/src/org/python/antlr/ast/Print.java trunk/jython/src/org/python/antlr/ast/Raise.java trunk/jython/src/org/python/antlr/ast/Repr.java trunk/jython/src/org/python/antlr/ast/Return.java trunk/jython/src/org/python/antlr/ast/Str.java trunk/jython/src/org/python/antlr/ast/Subscript.java trunk/jython/src/org/python/antlr/ast/TryExcept.java trunk/jython/src/org/python/antlr/ast/TryFinally.java trunk/jython/src/org/python/antlr/ast/Tuple.java trunk/jython/src/org/python/antlr/ast/UnaryOp.java trunk/jython/src/org/python/antlr/ast/While.java trunk/jython/src/org/python/antlr/ast/With.java trunk/jython/src/org/python/antlr/ast/Yield.java trunk/jython/src/templates/mappings Added Paths: ----------- trunk/jython/src/org/python/antlr/op/AddDerived.java trunk/jython/src/org/python/antlr/op/AndDerived.java trunk/jython/src/org/python/antlr/op/AugLoadDerived.java trunk/jython/src/org/python/antlr/op/AugStoreDerived.java trunk/jython/src/org/python/antlr/op/BitAndDerived.java trunk/jython/src/org/python/antlr/op/BitOrDerived.java trunk/jython/src/org/python/antlr/op/BitXorDerived.java trunk/jython/src/org/python/antlr/op/DelDerived.java trunk/jython/src/org/python/antlr/op/DivDerived.java trunk/jython/src/org/python/antlr/op/EqDerived.java trunk/jython/src/org/python/antlr/op/FloorDivDerived.java trunk/jython/src/org/python/antlr/op/GtDerived.java trunk/jython/src/org/python/antlr/op/GtEDerived.java trunk/jython/src/org/python/antlr/op/InDerived.java trunk/jython/src/org/python/antlr/op/InvertDerived.java trunk/jython/src/org/python/antlr/op/IsDerived.java trunk/jython/src/org/python/antlr/op/IsNotDerived.java trunk/jython/src/org/python/antlr/op/LShiftDerived.java trunk/jython/src/org/python/antlr/op/LoadDerived.java trunk/jython/src/org/python/antlr/op/LtDerived.java trunk/jython/src/org/python/antlr/op/LtEDerived.java trunk/jython/src/org/python/antlr/op/ModDerived.java trunk/jython/src/org/python/antlr/op/MultDerived.java trunk/jython/src/org/python/antlr/op/NotDerived.java trunk/jython/src/org/python/antlr/op/NotEqDerived.java trunk/jython/src/org/python/antlr/op/NotInDerived.java trunk/jython/src/org/python/antlr/op/OrDerived.java trunk/jython/src/org/python/antlr/op/ParamDerived.java trunk/jython/src/org/python/antlr/op/PowDerived.java trunk/jython/src/org/python/antlr/op/RShiftDerived.java trunk/jython/src/org/python/antlr/op/StoreDerived.java trunk/jython/src/org/python/antlr/op/SubDerived.java trunk/jython/src/org/python/antlr/op/UAddDerived.java trunk/jython/src/org/python/antlr/op/USubDerived.java trunk/jython/src/templates/op_Add.derived trunk/jython/src/templates/op_And.derived trunk/jython/src/templates/op_AugLoad.derived trunk/jython/src/templates/op_AugStore.derived trunk/jython/src/templates/op_BitAnd.derived trunk/jython/src/templates/op_BitOr.derived trunk/jython/src/templates/op_BitXor.derived trunk/jython/src/templates/op_Del.derived trunk/jython/src/templates/op_Div.derived trunk/jython/src/templates/op_Eq.derived trunk/jython/src/templates/op_FloorDiv.derived trunk/jython/src/templates/op_Gt.derived trunk/jython/src/templates/op_GtE.derived trunk/jython/src/templates/op_In.derived trunk/jython/src/templates/op_Invert.derived trunk/jython/src/templates/op_Is.derived trunk/jython/src/templates/op_IsNot.derived trunk/jython/src/templates/op_LShift.derived trunk/jython/src/templates/op_Load.derived trunk/jython/src/templates/op_Lt.derived trunk/jython/src/templates/op_LtE.derived trunk/jython/src/templates/op_Mod.derived trunk/jython/src/templates/op_Mult.derived trunk/jython/src/templates/op_Not.derived trunk/jython/src/templates/op_NotEq.derived trunk/jython/src/templates/op_NotIn.derived trunk/jython/src/templates/op_Or.derived trunk/jython/src/templates/op_Param.derived trunk/jython/src/templates/op_Pow.derived trunk/jython/src/templates/op_RShift.derived trunk/jython/src/templates/op_Store.derived trunk/jython/src/templates/op_Sub.derived trunk/jython/src/templates/op_UAdd.derived trunk/jython/src/templates/op_USub.derived Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/ast/asdl_antlr.py 2008-12-05 16:10:15 UTC (rev 5703) @@ -308,7 +308,7 @@ self.attributes(product, name, depth) - self.javaMethods(product, name, "%s" % name, product.fields, + self.javaMethods(product, name, name, True, product.fields, depth+1) self.emit("}", depth) @@ -334,7 +334,7 @@ self.attributes(cons, name, depth) - self.javaMethods(cons, cons.name, cons.name, cons.fields, depth+1) + self.javaMethods(cons, name, cons.name, False, cons.fields, depth+1) if "Context" in ifaces: self.emit("public void setContext(expr_contextType c) {", depth + 1) @@ -406,9 +406,9 @@ #XXX: this method used to emit a pickle(DataOutputStream ostream) for cPickle support. # If we want to re-add it, see Jython 2.2's pickle method in its ast nodes. - def javaMethods(self, type, clsname, ctorname, fields, depth): + def javaMethods(self, type, name, clsname, is_product, fields, depth): - self.javaConstructors(type, clsname, ctorname, fields, depth) + self.javaConstructors(type, name, clsname, is_product, fields, depth) # The toString() method self.emit('@ExposedGet(name = "repr")', depth) @@ -432,11 +432,11 @@ # The accept() method self.emit("public <R> R accept(VisitorIF<R> visitor) throws Exception {", depth) - if clsname == ctorname: - self.emit('return visitor.visit%s(this);' % clsname, depth+1) - else: + if is_product: self.emit('traverse(visitor);' % clsname, depth+1) self.emit('return null;' % clsname, depth+1) + else: + self.emit('return visitor.visit%s(this);' % clsname, depth+1) self.emit("}", depth) self.emit("", 0) @@ -461,39 +461,39 @@ self.emit('}', depth) self.emit("", 0) - def javaConstructors(self, type, clsname, ctorname, fields, depth): - self.emit("public %s(PyType subType) {" % (ctorname), depth) + def javaConstructors(self, type, name, clsname, is_product, fields, depth): + self.emit("public %s(PyType subType) {" % (clsname), depth) self.emit("super(subType);", depth + 1) self.emit("}", depth) if len(fields) > 0: - self.emit("public %s() {" % (ctorname), depth) + self.emit("public %s() {" % (clsname), depth) self.emit("this(TYPE);", depth + 1) self.emit("}", depth) fnames = ['"%s"' % f.name for f in fields] - if str(clsname) in ('stmt', 'expr', 'excepthandler'): + if str(name) in ('stmt', 'expr', 'excepthandler'): fnames.extend(['"lineno"', '"col_offset"']) fpargs = ", ".join(fnames) self.emit("@ExposedNew", depth) self.emit("@ExposedMethod", depth) - self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % ctorname, depth) - self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % ctorname, depth + 1) + self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % clsname, depth) + self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % clsname, depth + 1) self.emit('{%s}, %s);' % (fpargs, len(fields)), depth + 2) i = 0 for f in fields: self.emit("set%s(ap.getPyObject(%s));" % (str(f.name).capitalize(), str(i)), depth+1) i += 1 - if str(clsname) in ('stmt', 'expr', 'excepthandler'): - self.emit("PyObject lin = ap.getPyObject(%s, null);" % str(i), depth + 1) - self.emit("if (lin != null) {", depth + 1) + if str(name) in ('stmt', 'expr', 'excepthandler'): + self.emit("int lin = ap.getInt(%s, -1);" % str(i), depth + 1) + self.emit("if (lin != -1) {", depth + 1) self.emit("setLineno(lin);", depth + 2) self.emit("}", depth + 1) self.emit("", 0) - self.emit("PyObject col = ap.getPyObject(%s, null);" % str(i+1), depth + 1) - self.emit("if (col != null) {", depth + 1) + self.emit("int col = ap.getInt(%s, -1);" % str(i+1), depth + 1) + self.emit("if (col != -1) {", depth + 1) self.emit("setLineno(col);", depth + 2) self.emit("}", depth + 1) self.emit("", 0) @@ -502,7 +502,7 @@ self.emit("", 0) fpargs = ", ".join(["PyObject %s" % f.name for f in fields]) - self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("public %s(%s) {" % (clsname, fpargs), depth) for f in fields: self.emit("set%s(%s);" % (str(f.name).capitalize(), f.name), depth+1) @@ -512,7 +512,7 @@ token = asdl.Field('Token', 'token') token.typedef = False fpargs = ", ".join([self.fieldDef(f) for f in [token] + fields]) - self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("public %s(%s) {" % (clsname, fpargs), depth) self.emit("super(token);", depth+1) self.javaConstructorHelper(fields, depth) self.emit("}", depth) @@ -521,7 +521,7 @@ ttype = asdl.Field('int', 'ttype') ttype.typedef = False fpargs = ", ".join([self.fieldDef(f) for f in [ttype, token] + fields]) - self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("public %s(%s) {" % (clsname, fpargs), depth) self.emit("super(ttype, token);", depth+1) self.javaConstructorHelper(fields, depth) self.emit("}", depth) @@ -530,7 +530,7 @@ tree = asdl.Field('PythonTree', 'tree') tree.typedef = False fpargs = ", ".join([self.fieldDef(f) for f in [tree] + fields]) - self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("public %s(%s) {" % (clsname, fpargs), depth) self.emit("super(tree);", depth+1) self.javaConstructorHelper(fields, depth) self.emit("}", depth) Modified: trunk/jython/src/org/python/antlr/ast/Assert.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assert.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Assert.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void Assert___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Assert", args, keywords, new String[] - {"test", "msg"}, 2); + {"test", "msg", "lineno", "col_offset"}, 2); setTest(ap.getPyObject(0)); setMsg(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Assert(PyObject test, PyObject msg) { Modified: trunk/jython/src/org/python/antlr/ast/Assign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assign.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Assign.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void Assign___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Assign", args, keywords, new String[] - {"targets", "value"}, 2); + {"targets", "value", "lineno", "col_offset"}, 2); setTargets(ap.getPyObject(0)); setValue(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Assign(PyObject targets, PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/Attribute.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Attribute.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Attribute.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -89,10 +89,20 @@ @ExposedMethod public void Attribute___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Attribute", args, keywords, new String[] - {"value", "attr", "ctx"}, 3); + {"value", "attr", "ctx", "lineno", "col_offset"}, 3); setValue(ap.getPyObject(0)); setAttr(ap.getPyObject(1)); setCtx(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Attribute(PyObject value, PyObject attr, PyObject ctx) { Modified: trunk/jython/src/org/python/antlr/ast/AugAssign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssign.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/AugAssign.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void AugAssign___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("AugAssign", args, keywords, new String[] - {"target", "op", "value"}, 3); + {"target", "op", "value", "lineno", "col_offset"}, 3); setTarget(ap.getPyObject(0)); setOp(ap.getPyObject(1)); setValue(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public AugAssign(PyObject target, PyObject op, PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/BinOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/BinOp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void BinOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("BinOp", args, keywords, new String[] - {"left", "op", "right"}, 3); + {"left", "op", "right", "lineno", "col_offset"}, 3); setLeft(ap.getPyObject(0)); setOp(ap.getPyObject(1)); setRight(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public BinOp(PyObject left, PyObject op, PyObject right) { Modified: trunk/jython/src/org/python/antlr/ast/BoolOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/BoolOp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void BoolOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("BoolOp", args, keywords, new String[] - {"op", "values"}, 2); + {"op", "values", "lineno", "col_offset"}, 2); setOp(ap.getPyObject(0)); setValues(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public BoolOp(PyObject op, PyObject values) { Modified: trunk/jython/src/org/python/antlr/ast/Call.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Call.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Call.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -115,12 +115,22 @@ @ExposedMethod public void Call___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Call", args, keywords, new String[] - {"func", "args", "keywords", "starargs", "kwargs"}, 5); + {"func", "args", "keywords", "starargs", "kwargs", "lineno", "col_offset"}, 5); setFunc(ap.getPyObject(0)); setArgs(ap.getPyObject(1)); setKeywords(ap.getPyObject(2)); setStarargs(ap.getPyObject(3)); setKwargs(ap.getPyObject(4)); + int lin = ap.getInt(5, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(6, -1); + if (col != -1) { + setLineno(col); + } + } public Call(PyObject func, PyObject args, PyObject keywords, PyObject starargs, PyObject Modified: trunk/jython/src/org/python/antlr/ast/ClassDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDef.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/ClassDef.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -103,11 +103,21 @@ @ExposedMethod public void ClassDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ClassDef", args, keywords, new String[] - {"name", "bases", "body", "decorator_list"}, 4); + {"name", "bases", "body", "decorator_list", "lineno", "col_offset"}, 4); setName(ap.getPyObject(0)); setBases(ap.getPyObject(1)); setBody(ap.getPyObject(2)); setDecorator_list(ap.getPyObject(3)); + int lin = ap.getInt(4, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(5, -1); + if (col != -1) { + setLineno(col); + } + } public ClassDef(PyObject name, PyObject bases, PyObject body, PyObject decorator_list) { Modified: trunk/jython/src/org/python/antlr/ast/Compare.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Compare.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Compare.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void Compare___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Compare", args, keywords, new String[] - {"left", "ops", "comparators"}, 3); + {"left", "ops", "comparators", "lineno", "col_offset"}, 3); setLeft(ap.getPyObject(0)); setOps(ap.getPyObject(1)); setComparators(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Compare(PyObject left, PyObject ops, PyObject comparators) { Modified: trunk/jython/src/org/python/antlr/ast/Delete.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Delete.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Delete.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Delete___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Delete", args, keywords, new String[] - {"targets"}, 1); + {"targets", "lineno", "col_offset"}, 1); setTargets(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Delete(PyObject targets) { Modified: trunk/jython/src/org/python/antlr/ast/Dict.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Dict.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Dict.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void Dict___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Dict", args, keywords, new String[] - {"keys", "values"}, 2); + {"keys", "values", "lineno", "col_offset"}, 2); setKeys(ap.getPyObject(0)); setValues(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Dict(PyObject keys, PyObject values) { Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void ExceptHandler___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ExceptHandler", args, keywords, new String[] - {"excepttype", "name", "body"}, 3); + {"excepttype", "name", "body", "lineno", "col_offset"}, 3); setExcepttype(ap.getPyObject(0)); setName(ap.getPyObject(1)); setBody(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public ExceptHandler(PyObject excepttype, PyObject name, PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/Exec.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Exec.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Exec.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void Exec___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Exec", args, keywords, new String[] - {"body", "globals", "locals"}, 3); + {"body", "globals", "locals", "lineno", "col_offset"}, 3); setBody(ap.getPyObject(0)); setGlobals(ap.getPyObject(1)); setLocals(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Exec(PyObject body, PyObject globals, PyObject locals) { Modified: trunk/jython/src/org/python/antlr/ast/Expr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Expr.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Expr.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Expr___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Expr", args, keywords, new String[] - {"value"}, 1); + {"value", "lineno", "col_offset"}, 1); setValue(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Expr(PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/For.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/For.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/For.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -102,11 +102,21 @@ @ExposedMethod public void For___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("For", args, keywords, new String[] - {"target", "iter", "body", "orelse"}, 4); + {"target", "iter", "body", "orelse", "lineno", "col_offset"}, 4); setTarget(ap.getPyObject(0)); setIter(ap.getPyObject(1)); setBody(ap.getPyObject(2)); setOrelse(ap.getPyObject(3)); + int lin = ap.getInt(4, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(5, -1); + if (col != -1) { + setLineno(col); + } + } public For(PyObject target, PyObject iter, PyObject body, PyObject orelse) { Modified: trunk/jython/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -103,11 +103,21 @@ @ExposedMethod public void FunctionDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("FunctionDef", args, keywords, new String[] - {"name", "args", "body", "decorator_list"}, 4); + {"name", "args", "body", "decorator_list", "lineno", "col_offset"}, 4); setName(ap.getPyObject(0)); setArgs(ap.getPyObject(1)); setBody(ap.getPyObject(2)); setDecorator_list(ap.getPyObject(3)); + int lin = ap.getInt(4, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(5, -1); + if (col != -1) { + setLineno(col); + } + } public FunctionDef(PyObject name, PyObject args, PyObject body, PyObject decorator_list) { Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void GeneratorExp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("GeneratorExp", args, keywords, new String[] - {"elt", "generators"}, 2); + {"elt", "generators", "lineno", "col_offset"}, 2); setElt(ap.getPyObject(0)); setGenerators(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public GeneratorExp(PyObject elt, PyObject generators) { Modified: trunk/jython/src/org/python/antlr/ast/Global.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Global.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Global.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Global___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Global", args, keywords, new String[] - {"names"}, 1); + {"names", "lineno", "col_offset"}, 1); setNames(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Global(PyObject names) { Modified: trunk/jython/src/org/python/antlr/ast/If.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/If.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/If.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void If___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("If", args, keywords, new String[] - {"test", "body", "orelse"}, 3); + {"test", "body", "orelse", "lineno", "col_offset"}, 3); setTest(ap.getPyObject(0)); setBody(ap.getPyObject(1)); setOrelse(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public If(PyObject test, PyObject body, PyObject orelse) { Modified: trunk/jython/src/org/python/antlr/ast/IfExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/IfExp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void IfExp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("IfExp", args, keywords, new String[] - {"test", "body", "orelse"}, 3); + {"test", "body", "orelse", "lineno", "col_offset"}, 3); setTest(ap.getPyObject(0)); setBody(ap.getPyObject(1)); setOrelse(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public IfExp(PyObject test, PyObject body, PyObject orelse) { Modified: trunk/jython/src/org/python/antlr/ast/Import.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Import.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Import.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Import___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Import", args, keywords, new String[] - {"names"}, 1); + {"names", "lineno", "col_offset"}, 1); setNames(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Import(PyObject names) { Modified: trunk/jython/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -89,10 +89,20 @@ @ExposedMethod public void ImportFrom___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ImportFrom", args, keywords, new String[] - {"module", "names", "level"}, 3); + {"module", "names", "level", "lineno", "col_offset"}, 3); setModule(ap.getPyObject(0)); setNames(ap.getPyObject(1)); setLevel(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public ImportFrom(PyObject module, PyObject names, PyObject level) { Modified: trunk/jython/src/org/python/antlr/ast/Lambda.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Lambda.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Lambda.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void Lambda___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Lambda", args, keywords, new String[] - {"args", "body"}, 2); + {"args", "body", "lineno", "col_offset"}, 2); setArgs(ap.getPyObject(0)); setBody(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Lambda(PyObject args, PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/List.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/List.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/List.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void List___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("List", args, keywords, new String[] - {"elts", "ctx"}, 2); + {"elts", "ctx", "lineno", "col_offset"}, 2); setElts(ap.getPyObject(0)); setCtx(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public List(PyObject elts, PyObject ctx) { Modified: trunk/jython/src/org/python/antlr/ast/ListComp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListComp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/ListComp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void ListComp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ListComp", args, keywords, new String[] - {"elt", "generators"}, 2); + {"elt", "generators", "lineno", "col_offset"}, 2); setElt(ap.getPyObject(0)); setGenerators(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public ListComp(PyObject elt, PyObject generators) { Modified: trunk/jython/src/org/python/antlr/ast/Name.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Name.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Name.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -76,9 +76,19 @@ @ExposedMethod public void Name___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Name", args, keywords, new String[] - {"id", "ctx"}, 2); + {"id", "ctx", "lineno", "col_offset"}, 2); setId(ap.getPyObject(0)); setCtx(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Name(PyObject id, PyObject ctx) { Modified: trunk/jython/src/org/python/antlr/ast/Num.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Num.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Num.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Num___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Num", args, keywords, new String[] - {"n"}, 1); + {"n", "lineno", "col_offset"}, 1); setN(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Num(PyObject n) { Modified: trunk/jython/src/org/python/antlr/ast/Print.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Print.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Print.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -89,10 +89,20 @@ @ExposedMethod public void Print___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Print", args, keywords, new String[] - {"dest", "values", "nl"}, 3); + {"dest", "values", "nl", "lineno", "col_offset"}, 3); setDest(ap.getPyObject(0)); setValues(ap.getPyObject(1)); setNl(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Print(PyObject dest, PyObject values, PyObject nl) { Modified: trunk/jython/src/org/python/antlr/ast/Raise.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Raise.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Raise.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void Raise___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Raise", args, keywords, new String[] - {"excepttype", "inst", "tback"}, 3); + {"excepttype", "inst", "tback", "lineno", "col_offset"}, 3); setExcepttype(ap.getPyObject(0)); setInst(ap.getPyObject(1)); setTback(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Raise(PyObject excepttype, PyObject inst, PyObject tback) { Modified: trunk/jython/src/org/python/antlr/ast/Repr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Repr.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Repr.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Repr___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Repr", args, keywords, new String[] - {"value"}, 1); + {"value", "lineno", "col_offset"}, 1); setValue(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Repr(PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/Return.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Return.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Return.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Return___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Return", args, keywords, new String[] - {"value"}, 1); + {"value", "lineno", "col_offset"}, 1); setValue(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Return(PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/Str.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Str.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Str.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Str___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Str", args, keywords, new String[] - {"s"}, 1); + {"s", "lineno", "col_offset"}, 1); setS(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Str(PyObject s) { Modified: trunk/jython/src/org/python/antlr/ast/Subscript.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Subscript.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Subscript.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void Subscript___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Subscript", args, keywords, new String[] - {"value", "slice", "ctx"}, 3); + {"value", "slice", "ctx", "lineno", "col_offset"}, 3); setValue(ap.getPyObject(0)); setSlice(ap.getPyObject(1)); setCtx(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public Subscript(PyObject value, PyObject slice, PyObject ctx) { Modified: trunk/jython/src/org/python/antlr/ast/TryExcept.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExcept.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/TryExcept.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void TryExcept___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("TryExcept", args, keywords, new String[] - {"body", "handlers", "orelse"}, 3); + {"body", "handlers", "orelse", "lineno", "col_offset"}, 3); setBody(ap.getPyObject(0)); setHandlers(ap.getPyObject(1)); setOrelse(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public TryExcept(PyObject body, PyObject handlers, PyObject orelse) { Modified: trunk/jython/src/org/python/antlr/ast/TryFinally.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinally.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/TryFinally.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void TryFinally___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("TryFinally", args, keywords, new String[] - {"body", "finalbody"}, 2); + {"body", "finalbody", "lineno", "col_offset"}, 2); setBody(ap.getPyObject(0)); setFinalbody(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public TryFinally(PyObject body, PyObject finalbody) { Modified: trunk/jython/src/org/python/antlr/ast/Tuple.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Tuple.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Tuple.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void Tuple___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Tuple", args, keywords, new String[] - {"elts", "ctx"}, 2); + {"elts", "ctx", "lineno", "col_offset"}, 2); setElts(ap.getPyObject(0)); setCtx(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public Tuple(PyObject elts, PyObject ctx) { Modified: trunk/jython/src/org/python/antlr/ast/UnaryOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -75,9 +75,19 @@ @ExposedMethod public void UnaryOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("UnaryOp", args, keywords, new String[] - {"op", "operand"}, 2); + {"op", "operand", "lineno", "col_offset"}, 2); setOp(ap.getPyObject(0)); setOperand(ap.getPyObject(1)); + int lin = ap.getInt(2, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(3, -1); + if (col != -1) { + setLineno(col); + } + } public UnaryOp(PyObject op, PyObject operand) { Modified: trunk/jython/src/org/python/antlr/ast/While.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/While.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/While.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -88,10 +88,20 @@ @ExposedMethod public void While___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("While", args, keywords, new String[] - {"test", "body", "orelse"}, 3); + {"test", "body", "orelse", "lineno", "col_offset"}, 3); setTest(ap.getPyObject(0)); setBody(ap.getPyObject(1)); setOrelse(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public While(PyObject test, PyObject body, PyObject orelse) { Modified: trunk/jython/src/org/python/antlr/ast/With.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/With.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/With.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -89,10 +89,20 @@ @ExposedMethod public void With___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("With", args, keywords, new String[] - {"context_expr", "optional_vars", "body"}, 3); + {"context_expr", "optional_vars", "body", "lineno", "col_offset"}, 3); setContext_expr(ap.getPyObject(0)); setOptional_vars(ap.getPyObject(1)); setBody(ap.getPyObject(2)); + int lin = ap.getInt(3, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(4, -1); + if (col != -1) { + setLineno(col); + } + } public With(PyObject context_expr, PyObject optional_vars, PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/Yield.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Yield.java 2008-12-05 14:26:10 UTC (rev 5702) +++ trunk/jython/src/org/python/antlr/ast/Yield.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -62,8 +62,18 @@ @ExposedMethod public void Yield___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Yield", args, keywords, new String[] - {"value"}, 1); + {"value", "lineno", "col_offset"}, 1); setValue(ap.getPyObject(0)); + int lin = ap.getInt(1, -1); + if (lin != -1) { + setLineno(lin); + } + + int col = ap.getInt(2, -1); + if (col != -1) { + setLineno(col); + } + } public Yield(PyObject value) { Added: trunk/jython/src/org/python/antlr/op/AddDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/op/AddDerived.java (rev 0) +++ trunk/jython/src/org/python/antlr/op/AddDerived.java 2008-12-05 16:10:15 UTC (rev 5703) @@ -0,0 +1,1156 @@ +/* Generated file, do not modify. See jython/src/templates/gderived.py. */ +package org.python.antlr.op; + +import org.python.core.*; + +public class AddDerived extends Add implements Slotted { + + public PyObject getSlot(int index) { + return slots[index]; + } + + public void setSlot(int index,PyObject value) { + slots[index]=value; + } + + private PyObject[]slots; + + private PyObject dict; + + public PyObject fastGetDict() { + return dict; + } + + public PyObject getDict() { + return dict; + } + + public void setDict(PyObject newDict) { + if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { + dict=newDict; + } else { + throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); + } + } + + public void delDict() { + // deleting an object's instance dict makes it grow a new one + dict=new PyStringMap(); + } + + public AddDerived(PyType subtype) { + super(subtype); + slots=new PyObject[subtype.getNumSlots()]; + dict=subtype.instDict(); + } + + public PyString __str__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__str__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__str__(); + } + + public PyString __repr__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__repr__(); + } + + public PyString __hex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__hex__(); + } + + public PyString __oct__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__oct__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__oct__(); + } + + public PyFloat __float__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__float__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyFloat) + return(PyFloat)res; + throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); + } + return super.__float__(); + } + + public PyComplex __complex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__complex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyComplex) + return(PyComplex)res; + throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); + } + return super.__complex__(); + } + + public PyObject __pos__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pos__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__pos__(); + } + + public PyObject __neg__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__neg__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__neg__(); + } + + public PyObject __abs__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__abs__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__abs__(); + } + + public PyObject __invert__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__invert__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__invert__(); + } + + public PyObject __reduce__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__reduce__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__reduce__(); + } + + public PyObject __add__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__add__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__add__(other); + } + + public PyObject __radd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__radd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__radd__(other); + } + + public PyObject __sub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__sub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__sub__(other); + } + + public PyObject __rsub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rsub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rsub__(other); + } + + public PyObject __mul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__mul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__mul__(other); + } + + public PyObject __rmul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rmul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rmul__(other); + } + + public PyObject __div__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__div__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__div__(other); + } + + public PyObject __rdiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rdiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rdiv__(other); + } + + public PyObject __floordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__floordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__floordiv__(other); + } + + public PyObject __rfloordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rfloordiv__"); + if (impl!=null) { + Py... [truncated message content] |
From: <fwi...@us...> - 2008-12-05 14:26:17
|
Revision: 5702 http://jython.svn.sourceforge.net/jython/?rev=5702&view=rev Author: fwierzbicki Date: 2008-12-05 14:26:10 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Derived classes for org/python/antlr/ast/* Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/ast/Assert.java trunk/jython/src/org/python/antlr/ast/Assign.java trunk/jython/src/org/python/antlr/ast/Attribute.java trunk/jython/src/org/python/antlr/ast/AugAssign.java trunk/jython/src/org/python/antlr/ast/BinOp.java trunk/jython/src/org/python/antlr/ast/BoolOp.java trunk/jython/src/org/python/antlr/ast/Break.java trunk/jython/src/org/python/antlr/ast/Call.java trunk/jython/src/org/python/antlr/ast/ClassDef.java trunk/jython/src/org/python/antlr/ast/Compare.java trunk/jython/src/org/python/antlr/ast/Continue.java trunk/jython/src/org/python/antlr/ast/Delete.java trunk/jython/src/org/python/antlr/ast/Dict.java trunk/jython/src/org/python/antlr/ast/Ellipsis.java trunk/jython/src/org/python/antlr/ast/ExceptHandler.java trunk/jython/src/org/python/antlr/ast/Exec.java trunk/jython/src/org/python/antlr/ast/Expr.java trunk/jython/src/org/python/antlr/ast/Expression.java trunk/jython/src/org/python/antlr/ast/ExtSlice.java trunk/jython/src/org/python/antlr/ast/For.java trunk/jython/src/org/python/antlr/ast/FunctionDef.java trunk/jython/src/org/python/antlr/ast/GeneratorExp.java trunk/jython/src/org/python/antlr/ast/Global.java trunk/jython/src/org/python/antlr/ast/If.java trunk/jython/src/org/python/antlr/ast/IfExp.java trunk/jython/src/org/python/antlr/ast/Import.java trunk/jython/src/org/python/antlr/ast/ImportFrom.java trunk/jython/src/org/python/antlr/ast/Index.java trunk/jython/src/org/python/antlr/ast/Interactive.java trunk/jython/src/org/python/antlr/ast/Lambda.java trunk/jython/src/org/python/antlr/ast/List.java trunk/jython/src/org/python/antlr/ast/ListComp.java trunk/jython/src/org/python/antlr/ast/Module.java trunk/jython/src/org/python/antlr/ast/Name.java trunk/jython/src/org/python/antlr/ast/Num.java trunk/jython/src/org/python/antlr/ast/Pass.java trunk/jython/src/org/python/antlr/ast/Print.java trunk/jython/src/org/python/antlr/ast/Raise.java trunk/jython/src/org/python/antlr/ast/Repr.java trunk/jython/src/org/python/antlr/ast/Return.java trunk/jython/src/org/python/antlr/ast/Slice.java trunk/jython/src/org/python/antlr/ast/Str.java trunk/jython/src/org/python/antlr/ast/Subscript.java trunk/jython/src/org/python/antlr/ast/Suite.java trunk/jython/src/org/python/antlr/ast/TryExcept.java trunk/jython/src/org/python/antlr/ast/TryFinally.java trunk/jython/src/org/python/antlr/ast/Tuple.java trunk/jython/src/org/python/antlr/ast/UnaryOp.java trunk/jython/src/org/python/antlr/ast/While.java trunk/jython/src/org/python/antlr/ast/With.java trunk/jython/src/org/python/antlr/ast/Yield.java trunk/jython/src/org/python/antlr/ast/alias.java trunk/jython/src/org/python/antlr/ast/arguments.java trunk/jython/src/org/python/antlr/ast/comprehension.java trunk/jython/src/org/python/antlr/ast/keyword.java trunk/jython/src/templates/mappings Added Paths: ----------- trunk/jython/src/org/python/antlr/ast/AssertDerived.java trunk/jython/src/org/python/antlr/ast/AssignDerived.java trunk/jython/src/org/python/antlr/ast/AttributeDerived.java trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java trunk/jython/src/org/python/antlr/ast/BinOpDerived.java trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java trunk/jython/src/org/python/antlr/ast/BreakDerived.java trunk/jython/src/org/python/antlr/ast/CallDerived.java trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java trunk/jython/src/org/python/antlr/ast/CompareDerived.java trunk/jython/src/org/python/antlr/ast/ContinueDerived.java trunk/jython/src/org/python/antlr/ast/DeleteDerived.java trunk/jython/src/org/python/antlr/ast/DictDerived.java trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java trunk/jython/src/org/python/antlr/ast/ExecDerived.java trunk/jython/src/org/python/antlr/ast/ExprDerived.java trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java trunk/jython/src/org/python/antlr/ast/ForDerived.java trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java trunk/jython/src/org/python/antlr/ast/GlobalDerived.java trunk/jython/src/org/python/antlr/ast/IfDerived.java trunk/jython/src/org/python/antlr/ast/IfExpDerived.java trunk/jython/src/org/python/antlr/ast/ImportDerived.java trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java trunk/jython/src/org/python/antlr/ast/IndexDerived.java trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java trunk/jython/src/org/python/antlr/ast/LambdaDerived.java trunk/jython/src/org/python/antlr/ast/ListCompDerived.java trunk/jython/src/org/python/antlr/ast/ListDerived.java trunk/jython/src/org/python/antlr/ast/ModuleDerived.java trunk/jython/src/org/python/antlr/ast/NameDerived.java trunk/jython/src/org/python/antlr/ast/NumDerived.java trunk/jython/src/org/python/antlr/ast/PassDerived.java trunk/jython/src/org/python/antlr/ast/PrintDerived.java trunk/jython/src/org/python/antlr/ast/RaiseDerived.java trunk/jython/src/org/python/antlr/ast/ReprDerived.java trunk/jython/src/org/python/antlr/ast/ReturnDerived.java trunk/jython/src/org/python/antlr/ast/SliceDerived.java trunk/jython/src/org/python/antlr/ast/StrDerived.java trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java trunk/jython/src/org/python/antlr/ast/SuiteDerived.java trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java trunk/jython/src/org/python/antlr/ast/TupleDerived.java trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java trunk/jython/src/org/python/antlr/ast/WhileDerived.java trunk/jython/src/org/python/antlr/ast/WithDerived.java trunk/jython/src/org/python/antlr/ast/YieldDerived.java trunk/jython/src/org/python/antlr/ast/aliasDerived.java trunk/jython/src/org/python/antlr/ast/argumentsDerived.java trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java trunk/jython/src/org/python/antlr/ast/keywordDerived.java trunk/jython/src/templates/ast_Assert.derived trunk/jython/src/templates/ast_Assign.derived trunk/jython/src/templates/ast_Attribute.derived trunk/jython/src/templates/ast_AugAssign.derived trunk/jython/src/templates/ast_BinOp.derived trunk/jython/src/templates/ast_BoolOp.derived trunk/jython/src/templates/ast_Break.derived trunk/jython/src/templates/ast_Call.derived trunk/jython/src/templates/ast_ClassDef.derived trunk/jython/src/templates/ast_Compare.derived trunk/jython/src/templates/ast_Continue.derived trunk/jython/src/templates/ast_Delete.derived trunk/jython/src/templates/ast_Dict.derived trunk/jython/src/templates/ast_Ellipsis.derived trunk/jython/src/templates/ast_ExceptHandler.derived trunk/jython/src/templates/ast_Exec.derived trunk/jython/src/templates/ast_Expr.derived trunk/jython/src/templates/ast_Expression.derived trunk/jython/src/templates/ast_ExtSlice.derived trunk/jython/src/templates/ast_For.derived trunk/jython/src/templates/ast_FunctionDef.derived trunk/jython/src/templates/ast_GeneratorExp.derived trunk/jython/src/templates/ast_Global.derived trunk/jython/src/templates/ast_If.derived trunk/jython/src/templates/ast_IfExp.derived trunk/jython/src/templates/ast_Import.derived trunk/jython/src/templates/ast_ImportFrom.derived trunk/jython/src/templates/ast_Index.derived trunk/jython/src/templates/ast_Interactive.derived trunk/jython/src/templates/ast_Lambda.derived trunk/jython/src/templates/ast_List.derived trunk/jython/src/templates/ast_ListComp.derived trunk/jython/src/templates/ast_Module.derived trunk/jython/src/templates/ast_Name.derived trunk/jython/src/templates/ast_Num.derived trunk/jython/src/templates/ast_Pass.derived trunk/jython/src/templates/ast_Print.derived trunk/jython/src/templates/ast_Raise.derived trunk/jython/src/templates/ast_Repr.derived trunk/jython/src/templates/ast_Return.derived trunk/jython/src/templates/ast_Slice.derived trunk/jython/src/templates/ast_Str.derived trunk/jython/src/templates/ast_Subscript.derived trunk/jython/src/templates/ast_Suite.derived trunk/jython/src/templates/ast_TryExcept.derived trunk/jython/src/templates/ast_TryFinally.derived trunk/jython/src/templates/ast_Tuple.derived trunk/jython/src/templates/ast_UnaryOp.derived trunk/jython/src/templates/ast_While.derived trunk/jython/src/templates/ast_With.derived trunk/jython/src/templates/ast_Yield.derived trunk/jython/src/templates/ast_alias.derived trunk/jython/src/templates/ast_arguments.derived trunk/jython/src/templates/ast_comprehension.derived trunk/jython/src/templates/ast_keyword.derived Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2008-12-05 11:38:02 UTC (rev 5701) +++ trunk/jython/ast/asdl_antlr.py 2008-12-05 14:26:10 UTC (rev 5702) @@ -462,16 +462,19 @@ self.emit("", 0) def javaConstructors(self, type, clsname, ctorname, fields, depth): + self.emit("public %s(PyType subType) {" % (ctorname), depth) + self.emit("super(subType);", depth + 1) + self.emit("}", depth) + if len(fields) > 0: self.emit("public %s() {" % (ctorname), depth) self.emit("this(TYPE);", depth + 1) self.emit("}", depth) - self.emit("public %s(PyType subType) {" % (ctorname), depth) - self.emit("super(subType);", depth + 1) - self.emit("}", depth) - - fpargs = ", ".join(['"%s"' % f.name for f in fields]) + fnames = ['"%s"' % f.name for f in fields] + if str(clsname) in ('stmt', 'expr', 'excepthandler'): + fnames.extend(['"lineno"', '"col_offset"']) + fpargs = ", ".join(fnames) self.emit("@ExposedNew", depth) self.emit("@ExposedMethod", depth) self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % ctorname, depth) @@ -482,6 +485,19 @@ self.emit("set%s(ap.getPyObject(%s));" % (str(f.name).capitalize(), str(i)), depth+1) i += 1 + if str(clsname) in ('stmt', 'expr', 'excepthandler'): + self.emit("PyObject lin = ap.getPyObject(%s, null);" % str(i), depth + 1) + self.emit("if (lin != null) {", depth + 1) + self.emit("setLineno(lin);", depth + 2) + self.emit("}", depth + 1) + self.emit("", 0) + + self.emit("PyObject col = ap.getPyObject(%s, null);" % str(i+1), depth + 1) + self.emit("if (col != null) {", depth + 1) + self.emit("setLineno(col);", depth + 2) + self.emit("}", depth + 1) + self.emit("", 0) + self.emit("}", depth) self.emit("", 0) Modified: trunk/jython/src/org/python/antlr/ast/Assert.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assert.java 2008-12-05 11:38:02 UTC (rev 5701) +++ trunk/jython/src/org/python/antlr/ast/Assert.java 2008-12-05 14:26:10 UTC (rev 5702) @@ -65,12 +65,12 @@ @ExposedGet(name = "_attributes") public PyString[] get_attributes() { return attributes; } + public Assert(PyType subType) { + super(subType); + } public Assert() { this(TYPE); } - public Assert(PyType subType) { - super(subType); - } @ExposedNew @ExposedMethod public void Assert___init__(PyObject[] args, String[] keywords) { Added: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java (rev 0) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2008-12-05 14:26:10 UTC (rev 5702) @@ -0,0 +1,1156 @@ +/* Generated file, do not modify. See jython/src/templates/gderived.py. */ +package org.python.antlr.ast; + +import org.python.core.*; + +public class AssertDerived extends Assert implements Slotted { + + public PyObject getSlot(int index) { + return slots[index]; + } + + public void setSlot(int index,PyObject value) { + slots[index]=value; + } + + private PyObject[]slots; + + private PyObject dict; + + public PyObject fastGetDict() { + return dict; + } + + public PyObject getDict() { + return dict; + } + + public void setDict(PyObject newDict) { + if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { + dict=newDict; + } else { + throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); + } + } + + public void delDict() { + // deleting an object's instance dict makes it grow a new one + dict=new PyStringMap(); + } + + public AssertDerived(PyType subtype) { + super(subtype); + slots=new PyObject[subtype.getNumSlots()]; + dict=subtype.instDict(); + } + + public PyString __str__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__str__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__str__(); + } + + public PyString __repr__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__repr__(); + } + + public PyString __hex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__hex__(); + } + + public PyString __oct__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__oct__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__oct__(); + } + + public PyFloat __float__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__float__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyFloat) + return(PyFloat)res; + throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); + } + return super.__float__(); + } + + public PyComplex __complex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__complex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyComplex) + return(PyComplex)res; + throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); + } + return super.__complex__(); + } + + public PyObject __pos__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pos__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__pos__(); + } + + public PyObject __neg__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__neg__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__neg__(); + } + + public PyObject __abs__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__abs__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__abs__(); + } + + public PyObject __invert__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__invert__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__invert__(); + } + + public PyObject __reduce__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__reduce__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__reduce__(); + } + + public PyObject __add__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__add__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__add__(other); + } + + public PyObject __radd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__radd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__radd__(other); + } + + public PyObject __sub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__sub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__sub__(other); + } + + public PyObject __rsub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rsub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rsub__(other); + } + + public PyObject __mul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__mul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__mul__(other); + } + + public PyObject __rmul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rmul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rmul__(other); + } + + public PyObject __div__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__div__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__div__(other); + } + + public PyObject __rdiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rdiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rdiv__(other); + } + + public PyObject __floordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__floordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__floordiv__(other); + } + + public PyObject __rfloordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rfloordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rfloordiv__(other); + } + + public PyObject __truediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__truediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__truediv__(other); + } + + public PyObject __rtruediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rtruediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rtruediv__(other); + } + + public PyObject __mod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__mod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__mod__(other); + } + + public PyObject __rmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rmod__(other); + } + + public PyObject __divmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__divmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__divmod__(other); + } + + public PyObject __rdivmod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rdivmod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rdivmod__(other); + } + + public PyObject __rpow__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rpow__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rpow__(other); + } + + public PyObject __lshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__lshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__lshift__(other); + } + + public PyObject __rlshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rlshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rlshift__(other); + } + + public PyObject __rshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rshift__(other); + } + + public PyObject __rrshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rrshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rrshift__(other); + } + + public PyObject __and__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__and__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__and__(other); + } + + public PyObject __rand__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rand__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rand__(other); + } + + public PyObject __or__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__or__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__or__(other); + } + + public PyObject __ror__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ror__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ror__(other); + } + + public PyObject __xor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__xor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__xor__(other); + } + + public PyObject __rxor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__rxor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__rxor__(other); + } + + public PyObject __lt__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__lt__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__lt__(other); + } + + public PyObject __le__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__le__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__le__(other); + } + + public PyObject __gt__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__gt__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__gt__(other); + } + + public PyObject __ge__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ge__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ge__(other); + } + + public PyObject __eq__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__eq__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__eq__(other); + } + + public PyObject __ne__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ne__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ne__(other); + } + + public PyObject __iadd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iadd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__iadd__(other); + } + + public PyObject __isub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__isub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__isub__(other); + } + + public PyObject __imul__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__imul__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__imul__(other); + } + + public PyObject __idiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__idiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__idiv__(other); + } + + public PyObject __ifloordiv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ifloordiv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ifloordiv__(other); + } + + public PyObject __itruediv__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__itruediv__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__itruediv__(other); + } + + public PyObject __imod__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__imod__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__imod__(other); + } + + public PyObject __ipow__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ipow__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ipow__(other); + } + + public PyObject __ilshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ilshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ilshift__(other); + } + + public PyObject __irshift__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__irshift__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__irshift__(other); + } + + public PyObject __iand__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iand__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__iand__(other); + } + + public PyObject __ior__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ior__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ior__(other); + } + + public PyObject __ixor__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__ixor__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__ixor__(other); + } + + public PyObject __int__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__int__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger||res instanceof PyLong) + return(PyObject)res; + throw Py.TypeError("__int__"+" should return an integer"); + } + return super.__int__(); + } + + public PyObject __long__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__long__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyLong||res instanceof PyInteger) + return res; + throw Py.TypeError("__long__"+" returned non-"+"long"+" (type "+res.getType().fastGetName()+")"); + } + return super.__long__(); + } + + public int hashCode() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hash__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger) { + return((PyInteger)res).getValue(); + } else + if (res instanceof PyLong) { + return((PyLong)res).getValue().intValue(); + } + throw Py.TypeError("__hash__ should return a int"); + } + if (self_type.lookup("__eq__")!=null||self_type.lookup("__cmp__")!=null) { + throw Py.TypeError(String.format("unhashable type: '%.200s'",getType().fastGetName())); + } + return super.hashCode(); + } + + public PyUnicode __unicode__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__unicode__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyUnicode) + return(PyUnicode)res; + if (res instanceof PyString) + return new PyUnicode((PyString)res); + throw Py.TypeError("__unicode__"+" should return a "+"unicode"); + } + return super.__unicode__(); + } + + public int __cmp__(PyObject other) { + PyType self_type=getType(); + PyType[]where_type=new PyType[1]; + PyObject impl=self_type.lookup_where("__cmp__",where_type); + // Full Compatibility with CPython __cmp__: + // If the derived type don't override __cmp__, the + // *internal* super().__cmp__ should be called, not the + // exposed one. The difference is that the exposed __cmp__ + // throws a TypeError if the argument is an instance of the same type. + if (impl==null||where_type[0]==TYPE||Py.isSubClass(TYPE,where_type[0])) { + return super.__cmp__(other); + } + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) { + return-2; + } + int c=res.asInt(); + return c<0?-1:c>0?1:0; + } + + public boolean __nonzero__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__nonzero__"); + if (impl==null) { + impl=self_type.lookup("__len__"); + if (impl==null) + return super.__nonzero__(); + } + return impl.__get__(this,self_type).__call__().__nonzero__(); + } + + public boolean __contains__(PyObject o) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__contains__"); + if (impl==null) + return super.__contains__(o); + return impl.__get__(this,self_type).__call__(o).__nonzero__(); + } + + public int __len__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__len__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger) + return((PyInteger)res).getValue(); + throw Py.TypeError("__len__ should return a int"); + } + return super.__len__(); + } + + public PyObject __iter__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__iter__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + impl=self_type.lookup("__getitem__"); + if (impl==null) + return super.__iter__(); + return new PySequenceIter(this); + } + + public PyObject __iternext__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("next"); + if (impl!=null) { + try { + return impl.__get__(this,self_type).__call__(); + } catch (PyException exc) { + if (Py.matchException(exc,Py.StopIteration)) + return null; + throw exc; + } + } + return super.__iternext__(); // ??? + } + + public PyObject __finditem__(PyObject key) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(key); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + + public PyObject __finditem__(int key) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + try { + return impl.__get__(this,self_type).__call__(new PyInteger(key)); + } catch (PyException exc) { + if (Py.matchException(exc,Py.LookupError)) + return null; + throw exc; + } + return super.__finditem__(key); + } + + public PyObject __getitem__(PyObject key) { + // Same as __finditem__, without swallowing LookupErrors. This allows + // __getitem__ implementations written in Python to raise custom + // exceptions (such as subclasses of KeyError). + // + // We are forced to duplicate the code, instead of defining __finditem__ + // in terms of __getitem__. That's because PyObject defines __getitem__ + // in terms of __finditem__. Therefore, we would end with an infinite + // loop when self_type.lookup("__getitem__") returns null: + // + // __getitem__ -> super.__getitem__ -> __finditem__ -> __getitem__ + // + // By duplicating the (short) lookup and call code, we are safe, because + // the call chains will be: + // + // __finditem__ -> super.__finditem__ + // + // __getitem__ -> super.__getitem__ -> __finditem__ -> super.__finditem__ + + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getitem__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(key); + return super.__getitem__(key); + } + + public void __setitem__(PyObject key,PyObject value) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setitem__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(key,value); + return; + } + super.__setitem__(key,value); + } + + public PyObject __getslice__(PyObject start,PyObject stop,PyObject step) { // ??? + if (step!=null) { + return __getitem__(new PySlice(start,stop,step)); + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__getslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + return impl.__get__(this,self_type).__call__(indices[0],indices[1]); + } + return super.__getslice__(start,stop,step); + } + + public void __setslice__(PyObject start,PyObject stop,PyObject step,PyObject value) { + if (step!=null) { + __setitem__(new PySlice(start,stop,step),value); + return; + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + impl.__get__(this,self_type).__call__(indices[0],indices[1],value); + return; + } + super.__setslice__(start,stop,step,value); + } + + public void __delslice__(PyObject start,PyObject stop,PyObject step) { + if (step!=null) { + __delitem__(new PySlice(start,stop,step)); + return; + } + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delslice__"); + if (impl!=null) { + PyObject[]indices=PySlice.indices2(this,start,stop); + impl.__get__(this,self_type).__call__(indices[0],indices[1]); + return; + } + super.__delslice__(start,stop,step); + } + + public void __delitem__(PyObject key) { // ??? + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delitem__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(key); + return; + } + super.__delitem__(key); + } + + public PyObject __call__(PyObject args[],String keywords[]) { + ThreadState ts=Py.getThreadState(); + if (ts.recursion_depth++>ts.systemState.getrecursionlimit()) + throw Py.RuntimeError("maximum __call__ recursion depth exceeded"); + try { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__call__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(args,keywords); + return super.__call__(args,keywords); + } finally { + --ts.recursion_depth; + } + } + + public PyObject __findattr_ex__(String name) { + PyType self_type=getType(); + // TODO: We should speed this up. As the __getattribute__ slot almost never + // changes, it is a good candidate for caching, as PyClass does with + // __getattr__. See #1102. + PyObject getattribute=self_type.lookup("__getattribute__"); + PyString py_name=null; + PyException firstAttributeError=null; + try { + if (getattribute!=null) { + py_name=PyString.fromInterned(name); + return getattribute.__get__(this,self_type).__call__(py_name); + } else { + Py.Warning(String.format("__getattribute__ not found on type %s",self_type.getName())); + PyObject ret=super.__findattr_ex__(name); + if (ret!=null) { + return ret; + } // else: pass through to __getitem__ invocation + } + } catch (PyException e) { + if (!Py.matchException(e,Py.AttributeError)) { + throw e; + } else { + firstAttributeError=e; // saved to avoid swallowing custom AttributeErrors + // and pass through to __getattr__ invocation. + } + } + PyObject getattr=self_type.lookup("__getattr__"); + if (getattr!=null) { + if (py_name==null) { + py_name=PyString.fromInterned(name); + } + return getattr.__get__(this,self_type).__call__(py_name); + } + if (firstAttributeError!=null) { + throw firstAttributeError; + } + return null; + } + + public void __setattr__(String name,PyObject value) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__setattr__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value); + return; + } + super.__setattr__(name,value); + } + + public void __delattr__(String name) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delattr__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(PyString.fromInterned(name)); + return; + } + super.__delattr__(name); + } + + public PyObject __get__(PyObject obj,PyObject type) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__get__"); + if (impl!=null) { + if (obj==null) + obj=Py.None; + if (type==null) + type=Py.None; + return impl.__get__(this,self_type).__call__(obj,type); + } + return super.__get__(obj,type); + } + + public void __set__(PyObject obj,PyObject value) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__set__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(obj,value); + return; + } + super.__set__(obj,value); + } + + public void __delete__(PyObject obj) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__delete__"); + if (impl!=null) { + impl.__get__(this,self_type).__call__(obj); + return; + } + super.__delete__(obj); + } + + public PyObject __pow__(PyObject other,PyObject modulo) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pow__"); + if (impl!=null) { + PyObject res; + if (modulo==null) { + res=impl.__get__(this,self_type).__call__(other); + } else { + res=impl.__get__(this,self_type).__call__(other,modulo); + } + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__pow__(other,modulo); + } + + public void dispatch__init__(PyType type,PyObject[]args,String[]keywords) { + PyType self_type=getType(); + if (self_type.isSubType(type)) { + PyObject impl=self_type.lookup("__init__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(args,keywords); + if (res!=Py.None) { + throw Py.TypeError(String.format("__init__() should return None, not '%.200s'",res.getType().fastGetName())); + } + } + } + } + + public PyObject __index__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__index__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyInteger||res instanceof PyLong) { + return res; + } + throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName())); + } + return super.__index__(); + } + + public Object __tojava__(Class c) { + // If we are not being asked by the "default" conversion to java, then + // we can provide this as the result, as long as it is a instance of the + // specified class. Without this, derived.__tojava__(PyObject.class) + // would broke. (And that's not pure speculation: PyReflectedFunction's + // ReflectedArgs asks for things like that). + if ((c!=Object.class)&&(c.isInstance(this))) { + return this; + } + // Otherwise, we call the derived __tojava__, if it exists: + PyType self_type=getType(); + PyObject impl=self_type.lookup("__tojava__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava__(Object.class); + return super.__tojava__(c); + } + + public Object __coerce_ex__(PyObject o) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__coerce__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(o); + if (res==Py.NotImplemented) + return Py.None; + if (!(res instanceof PyTuple)) + throw Py.TypeError("__coerce__ didn't return a 2-tuple"); + return((PyTuple)res).getArray(); + } + return super.__coerce_ex__(o); + } + + public String toString() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (!(res instanceof PyString)) + throw Py.TypeError("__repr__ returned non-string (type "+res.getType().fastGetName()+")"); + return((PyString)res).toString(); + } + return super.toString(); + } + +} Modified: trunk/jython/src/org/python/antlr/ast/Assign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assign.java 2008-12-05 11:38:02 UTC (rev 5701) +++ trunk/jython/src/org/python/antlr/ast/Assign.java 2008-12-05 14:26:10 UTC (rev 5702) @@ -65,12 +65,12 @@ @ExposedGet(name = "_attributes") public PyString[] get_attributes() { return attributes; } + public Assign(PyType subType) { + super(subType); + } public Assign() { this(TYPE); } - public Assign(PyType subType) { - super(subType); - } @ExposedNew @ExposedMethod public void Assign___init__(PyObject[] args, String[] keywords) { Added: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java (rev 0) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2008-12-05 14:26:10 UTC (rev 5702) @@ -0,0 +1,1156 @@ +/* Generated file, do not modify. See jython/src/templates/gderived.py. */ +package org.python.antlr.ast; + +import org.python.core.*; + +public class AssignDerived extends Assign implements Slotted { + + public PyObject getSlot(int index) { + return slots[index]; + } + + public void setSlot(int index,PyObject value) { + slots[index]=value; + } + + private PyObject[]slots; + + private PyObject dict; + + public PyObject fastGetDict() { + return dict; + } + + public PyObject getDict() { + return dict; + } + + public void setDict(PyObject newDict) { + if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { + dict=newDict; + } else { + throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); + } + } + + public void delDict() { + // deleting an object's instance dict makes it grow a new one + dict=new PyStringMap(); + } + + public AssignDerived(PyType subtype) { + super(subtype); + slots=new PyObject[subtype.getNumSlots()]; + dict=subtype.instDict(); + } + + public PyString __str__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__str__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__str__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__str__(); + } + + public PyString __repr__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__repr__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__repr__(); + } + + public PyString __hex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__hex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__hex__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__hex__(); + } + + public PyString __oct__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__oct__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyString) + return(PyString)res; + throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); + } + return super.__oct__(); + } + + public PyFloat __float__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__float__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyFloat) + return(PyFloat)res; + throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); + } + return super.__float__(); + } + + public PyComplex __complex__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__complex__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(); + if (res instanceof PyComplex) + return(PyComplex)res; + throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); + } + return super.__complex__(); + } + + public PyObject __pos__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__pos__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__pos__(); + } + + public PyObject __neg__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__neg__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__neg__(); + } + + public PyObject __abs__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__abs__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__abs__(); + } + + public PyObject __invert__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__invert__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__invert__(); + } + + public PyObject __reduce__() { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__reduce__"); + if (impl!=null) + return impl.__get__(this,self_type).__call__(); + return super.__reduce__(); + } + + public PyObject __add__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__add__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__add__(other); + } + + public PyObject __radd__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__radd__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__radd__(other); + } + + public PyObject __sub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__sub__"); + if (impl!=null) { + PyObject res=impl.__get__(this,self_type).__call__(other); + if (res==Py.NotImplemented) + return null; + return res; + } + return super.__sub__(other); + } + + public PyObject __rsub__(PyObject other) { + PyType self_type=getType(); + PyObject impl=self_type.lookup("__r... [truncated message content] |
From: <cg...@us...> - 2008-12-05 12:22:35
|
Revision: 5701 http://jython.svn.sourceforge.net/jython/?rev=5701&view=rev Author: cgroves Date: 2008-12-05 11:38:02 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Avoid non-public interface methods similarly to non-public class methods Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/PyJavaType.java Modified: branches/newstyle-java-types/src/org/python/core/PyJavaType.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-05 11:21:55 UTC (rev 5700) +++ branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-05 11:38:02 UTC (rev 5701) @@ -327,6 +327,10 @@ private void handleSuperMethodArgCollisions() { for (Class iface : underlying_class.getInterfaces()) { for (Method meth : iface.getMethods()) { + if (!Modifier.isPublic(meth.getDeclaringClass().getModifiers())) { + // Ignore methods from non-public interfaces as they're similarly bugged + continue; + } String nmethname = normalize(meth.getName()); PyObject[] where = new PyObject[1]; PyObject obj = lookup_where(nmethname, where); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-05 11:21:59
|
Revision: 5700 http://jython.svn.sourceforge.net/jython/?rev=5700&view=rev Author: cgroves Date: 2008-12-05 11:21:55 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Make methods from superclasses and superinterfaces of private, protected or package protected classes call through their parent versions. Fixes blowups with a package protected implementation of attributes in sax. Modified Paths: -------------- branches/newstyle-java-types/Lib/test/test_java_visibility.py branches/newstyle-java-types/src/org/python/core/PyJavaType.java Added Paths: ----------- branches/newstyle-java-types/tests/java/org/python/tests/InterfaceCombination.java Modified: branches/newstyle-java-types/Lib/test/test_java_visibility.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_java_visibility.py 2008-12-05 09:06:12 UTC (rev 5699) +++ branches/newstyle-java-types/Lib/test/test_java_visibility.py 2008-12-05 11:21:55 UTC (rev 5700) @@ -1,6 +1,6 @@ import unittest from test import test_support -from org.python.tests import Invisible, SubVisible, Visible, VisibleOverride +from org.python.tests import InterfaceCombination, Invisible, SubVisible, Visible, VisibleOverride from org.python.tests import VisibilityResults as Results class VisibilityTest(unittest.TestCase): @@ -67,6 +67,21 @@ self.failUnless('visibleInstance' in c.__dict__, 'visibleInstance expected in %s __dict__' % c) + def test_interface_combination(self): + '''Checks that a private class that extends a public class and public interfaces has only the items + from the public bases visible''' + i = InterfaceCombination.newImplementation() + self.assertEquals(InterfaceCombination.NO_ARG_RESULT, i.getValue(), + "methods from IFace should be visible on Implementation") + self.assertEquals(InterfaceCombination.ONE_ARG_RESULT, i.getValue("one arg"), + "methods from IIFace should be visible on Implementation") + self.assertEquals(InterfaceCombination.TWO_ARG_RESULT, i.getValue("one arg", "two arg"), + "methods from Base should be visible on Implementation") + self.assertRaises(TypeError, i.getValue, "one arg", "two arg", "three arg", + "methods defined solely on Implementation shouldn't be visible") + self.assertFalse(hasattr(i, "internalMethod"), + "methods from private interfaces shouldn't be visible on a private class") + def test_main(): test_support.run_unittest(VisibilityTest) Modified: branches/newstyle-java-types/src/org/python/core/PyJavaType.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-05 09:06:12 UTC (rev 5699) +++ branches/newstyle-java-types/src/org/python/core/PyJavaType.java 2008-12-05 11:21:55 UTC (rev 5700) @@ -83,6 +83,7 @@ // org.python.core if (!Modifier.isPublic(underlying_class.getModifiers()) && !name.startsWith("org.python.core")) { + handleSuperMethodArgCollisions(); return; } @@ -308,6 +309,59 @@ } } + /** + * Private, protected or package protected classes that implement public interfaces or extend + * public classes can't have their implementations of the methods of their supertypes called + * through reflection due to Sun VM bug 4071957(http://tinyurl.com/le9vo). They can be called + * through the supertype version of the method though. Unfortunately we can't just let normal + * mro lookup of those methods handle routing the call to the correct version as a class can + * implement interfaces or classes that each have methods with the same name that takes + * different number or types of arguments. Instead this method goes through all interfaces + * implemented by this class, and combines same-named methods into a single PyReflectedFunction. + * + * Prior to Jython 2.5, this was handled in PyJavaClass.setMethods by setting methods in package + * protected classes accessible which made them callable through reflection. That had the + * drawback of failing when running in a security environment that didn't allow setting + * accessibility, so this method replaced it. + */ + private void handleSuperMethodArgCollisions() { + for (Class iface : underlying_class.getInterfaces()) { + for (Method meth : iface.getMethods()) { + String nmethname = normalize(meth.getName()); + PyObject[] where = new PyObject[1]; + PyObject obj = lookup_where(nmethname, where); + if (obj == null) { + // Nothing in our supertype hierarchy defines something with this name, so it + // must not be visible there. + continue; + } else if (where[0] == this) { + // This method is the only thing defining items in this class' dict, so it must + // be a PyReflectedFunction created here. See if it needs the current method + // added to it. + if (!((PyReflectedFunction)obj).handles(meth)) { + ((PyReflectedFunction)obj).addMethod(meth); + } + } else { + // There's something in a superclass with the same name. If this class extends a + // class and doesn't just implement something, the extended class is first in + // mro, so items defined on the extended class will show up here. Thanks to that + // and copying the base function, we can get away with just looping over + // interface methods. + PyReflectedFunction func; + if (obj instanceof PyReflectedFunction) { + func = ((PyReflectedFunction)obj).copy(); + if (!func.handles(meth)) { + func.addMethod(meth); + } + } else { + func = new PyReflectedFunction(meth); + } + dict.__setitem__(nmethname, func); + } + } + } + } + private static boolean declaredOnMember(Class<?> base, Member declaring) { return base == null || (declaring.getDeclaringClass() != base && base.isAssignableFrom(declaring.getDeclaringClass())); Added: branches/newstyle-java-types/tests/java/org/python/tests/InterfaceCombination.java =================================================================== --- branches/newstyle-java-types/tests/java/org/python/tests/InterfaceCombination.java (rev 0) +++ branches/newstyle-java-types/tests/java/org/python/tests/InterfaceCombination.java 2008-12-05 11:21:55 UTC (rev 5700) @@ -0,0 +1,49 @@ +package org.python.tests; + +public class InterfaceCombination { + + public static final String NO_ARG_RESULT = "no_arg_result"; + + public static final String ONE_ARG_RESULT = "one_arg_result"; + + public static final String TWO_ARG_RESULT = "two_arg_result"; + + public interface IFace { + String getValue(); + } + + public interface IIFace { + String getValue(String name); + } + + interface Hidden { + void internalMethod(); + } + + public static class Base { + public String getValue(String one, String two) { + return TWO_ARG_RESULT; + } + } + + private static class Implementation extends Base implements IFace, IIFace, Hidden { + + public String getValue(String one, String two, String three) { + return three; + } + + public String getValue() { + return NO_ARG_RESULT; + } + + public String getValue(String name) { + return ONE_ARG_RESULT; + } + + public void internalMethod() {} + } + + public static Object newImplementation() { + return new Implementation(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-05 09:06:23
|
Revision: 5699 http://jython.svn.sourceforge.net/jython/?rev=5699&view=rev Author: cgroves Date: 2008-12-05 09:06:12 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Don't worry about the count, just assert the things that should and shouldn't be visible Modified Paths: -------------- branches/newstyle-java-types/Lib/test/test_java_visibility.py Modified: branches/newstyle-java-types/Lib/test/test_java_visibility.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_java_visibility.py 2008-12-05 04:06:23 UTC (rev 5698) +++ branches/newstyle-java-types/Lib/test/test_java_visibility.py 2008-12-05 09:06:12 UTC (rev 5699) @@ -5,7 +5,10 @@ class VisibilityTest(unittest.TestCase): def test_invisible(self): - self.assertEquals([], dir(Invisible)) + for item in dir(Invisible): + self.assert_(not item.startswith("package")) + self.assert_(not item.startswith("private")) + self.assert_(not item.startswith("protected")) def test_protected_from_python_subclass(self): class SubVisible(Visible): @@ -22,8 +25,6 @@ self.assertEquals(Results.UNUSED, SubVisible(Results.UNUSED).visibleField) def test_visible(self): - self.assertEquals(5, len(dir(Visible))) - v = Visible() self.assertEquals(Results.PUBLIC_FIELD, v.visibleField) self.assertEquals(Results.PUBLIC_STATIC_FIELD, Visible.visibleStaticField) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-05 04:06:27
|
Revision: 5698 http://jython.svn.sourceforge.net/jython/?rev=5698&view=rev Author: cgroves Date: 2008-12-05 04:06:23 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Get test_jy_internals passing again Modified Paths: -------------- branches/newstyle-java-types/Lib/test/test_jy_internals.py branches/newstyle-java-types/src/org/python/core/IdImpl.java Modified: branches/newstyle-java-types/Lib/test/test_jy_internals.py =================================================================== --- branches/newstyle-java-types/Lib/test/test_jy_internals.py 2008-12-05 03:33:30 UTC (rev 5697) +++ branches/newstyle-java-types/Lib/test/test_jy_internals.py 2008-12-05 04:06:23 UTC (rev 5698) @@ -60,7 +60,7 @@ iarr = java.lang.Object.getClass(self.e) sdv = java.lang.Class.getMethod(long, 'scaledDoubleValue', [iarr]) import org.python.core.PyReflectedFunction as ReflFunc - self.sdv = ReflFunc(sdv) + self.sdv = ReflFunc([sdv]) def test_basic_roundtrip(self): e = self.e Modified: branches/newstyle-java-types/src/org/python/core/IdImpl.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/IdImpl.java 2008-12-05 03:33:30 UTC (rev 5697) +++ branches/newstyle-java-types/src/org/python/core/IdImpl.java 2008-12-05 04:06:23 UTC (rev 5698) @@ -43,6 +43,11 @@ } } + // Used by test_jy_internals + public int _internal_map_size() { + return objHashcodeToPyId.size(); + } + public void put(Object key, Object val) { cleanup(); objHashcodeToPyId.put(new WeakIdKey(key), val); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |