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: <fwi...@us...> - 2009-04-05 19:15:20
|
Revision: 6167 http://jython.svn.sourceforge.net/jython/?rev=6167&view=rev Author: fwierzbicki Date: 2009-04-05 19:15:19 +0000 (Sun, 05 Apr 2009) Log Message: ----------- remove sys.path appends that where not needed. Modified Paths: -------------- trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java Modified: trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java =================================================================== --- trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java 2009-04-05 18:42:28 UTC (rev 6166) +++ trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java 2009-04-05 19:15:19 UTC (rev 6167) @@ -14,10 +14,6 @@ @Override protected void setUp() throws Exception { PySystemState sys = new PySystemState(); - sys.path.append(new PyString("dist/Lib")); - sys.path.append(new PyString("dist/javalib/constantine.jar")); - sys.path.append(new PyString("dist/javalib/jna.jar")); - sys.path.append(new PyString("dist/javalib/jna-posix.jar")); interp = new PythonInterpreter(new PyStringMap(), sys); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-05 18:42:29
|
Revision: 6166 http://jython.svn.sourceforge.net/jython/?rev=6166&view=rev Author: pjenvey Date: 2009-04-05 18:42:28 +0000 (Sun, 05 Apr 2009) Log Message: ----------- fix ant javatest regrtest (the buildbot) unnecessarily compiling twice Modified Paths: -------------- trunk/jython/build.xml Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-04-05 18:29:58 UTC (rev 6165) +++ trunk/jython/build.xml 2009-04-05 18:42:28 UTC (rev 6166) @@ -504,6 +504,8 @@ <include name="**/*.properties" /> </fileset> </copy> + <!-- grammar must now be up to date --> + <property name="antlr.notneeded" value="true" /> </target> <!-- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-04-05 18:30:08
|
Revision: 6165 http://jython.svn.sourceforge.net/jython/?rev=6165&view=rev Author: fwierzbicki Date: 2009-04-05 18:29:58 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Fix for http://bugs.jython.org/issue1264 'is not' test exhibits incorrect behaviour when wrapping Java objects Included is a reshuffling of the patch test so that a regression test can pick it up. It isn't perfect since I had to use raw "assert" statements in the python, but it is run by the Java unit test IdentityTest. Thanks to Geoffrey French for the patch. Modified Paths: -------------- trunk/jython/ACKNOWLEDGMENTS trunk/jython/NEWS trunk/jython/src/org/python/core/PyObject.java Added Paths: ----------- trunk/jython/tests/java/org/python/tests/identity/ trunk/jython/tests/java/org/python/tests/identity/IdentityObject.java trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java trunk/jython/tests/python/ trunk/jython/tests/python/identity_test.py Modified: trunk/jython/ACKNOWLEDGMENTS =================================================================== --- trunk/jython/ACKNOWLEDGMENTS 2009-04-05 17:22:40 UTC (rev 6164) +++ trunk/jython/ACKNOWLEDGMENTS 2009-04-05 18:29:58 UTC (rev 6165) @@ -66,6 +66,7 @@ Nathan Franzen Aleks Totic Randolph Brown + Geoffrey French Local Variables: mode: indented-text Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-04-05 17:22:40 UTC (rev 6164) +++ trunk/jython/NEWS 2009-04-05 18:29:58 UTC (rev 6165) @@ -2,6 +2,7 @@ Jython 2.5.0 rc 1 Bugs fixed (new numbering due to move to Roundup) + - [ 1264 ] 'is not' test exhibits incorrect behaviour when wrapping Java objects - [ 1295 ] Setting a write-only bean property causes a NPE - [ 1272 ] ASTList ClassCastException - [ 1261 ] jython -c "import sys; sys.exit(1)" not giving correct exit code. Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-04-05 17:22:40 UTC (rev 6164) +++ trunk/jython/src/org/python/core/PyObject.java 2009-04-05 18:29:58 UTC (rev 6165) @@ -1633,7 +1633,7 @@ public PyObject _isnot(PyObject o) { // Access javaProxy directly here as is is for object identity, and at best getJavaProxy // will initialize a new object with a different identity - return this != o || javaProxy != o.javaProxy ? Py.True : Py.False; + return this != o && (javaProxy == null || javaProxy != o.javaProxy) ? Py.True : Py.False; } /** Added: trunk/jython/tests/java/org/python/tests/identity/IdentityObject.java =================================================================== --- trunk/jython/tests/java/org/python/tests/identity/IdentityObject.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/identity/IdentityObject.java 2009-04-05 18:29:58 UTC (rev 6165) @@ -0,0 +1,12 @@ +package org.python.tests.identity; + +public class IdentityObject { + + public IdentityObject() { + } + + public IdentityObject getThis() { + return this; + } + +} Added: trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java =================================================================== --- trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/identity/IdentityTest.java 2009-04-05 18:29:58 UTC (rev 6165) @@ -0,0 +1,28 @@ +package org.python.tests.identity; + +import junit.framework.TestCase; + +import org.python.core.PyString; +import org.python.core.PyStringMap; +import org.python.core.PySystemState; +import org.python.util.PythonInterpreter; + +public class IdentityTest extends TestCase { + + private PythonInterpreter interp; + + @Override + protected void setUp() throws Exception { + PySystemState sys = new PySystemState(); + sys.path.append(new PyString("dist/Lib")); + sys.path.append(new PyString("dist/javalib/constantine.jar")); + sys.path.append(new PyString("dist/javalib/jna.jar")); + sys.path.append(new PyString("dist/javalib/jna-posix.jar")); + interp = new PythonInterpreter(new PyStringMap(), sys); + } + + public void testReadonly() { + //This used to cause an NPE see http://bugs.jython.org/issue1295 + interp.execfile("tests/python/identity_test.py"); + } +} Added: trunk/jython/tests/python/identity_test.py =================================================================== --- trunk/jython/tests/python/identity_test.py (rev 0) +++ trunk/jython/tests/python/identity_test.py 2009-04-05 18:29:58 UTC (rev 6165) @@ -0,0 +1,18 @@ +from org.python.tests.identity import IdentityObject + +class PyIdentityObject (IdentityObject): + pass + +x = IdentityObject() +y = x.getThis() + +a = PyIdentityObject() +b = a.getThis() + +assert x is y +assert not(x is not y) +assert (x is y) != (x is not y) +assert a is b +assert not(a is not b) +assert (a is b) != (a is not b) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-04-05 17:22:43
|
Revision: 6164 http://jython.svn.sourceforge.net/jython/?rev=6164&view=rev Author: thobes Date: 2009-04-05 17:22:40 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Fix for http://bugs.jython.org/issue1110 Modified Paths: -------------- trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-04-05 03:18:39 UTC (rev 6163) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-04-05 17:22:40 UTC (rev 6164) @@ -449,10 +449,16 @@ * @return a resolved path String */ public String getPath(String path) { - if (path == null || new File(path).isAbsolute()) { + if (path == null) { return path; + } else { + File file = new File(path); + if (!file.isAbsolute()) { + file = new File(getCurrentWorkingDir(), path); + } + // This needs to be performed always to trim trailing backslashes on Windows + return file.getPath(); } - return new File(getCurrentWorkingDir(), path).getPath(); } public void callExitFunc() throws PyIgnoreMethodTag { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-05 03:19:00
|
Revision: 6163 http://jython.svn.sourceforge.net/jython/?rev=6163&view=rev Author: pjenvey Date: 2009-04-05 03:18:39 +0000 (Sun, 05 Apr 2009) Log Message: ----------- remove stop_at_java cruft -- remnants of old Java integration Modified Paths: -------------- trunk/jython/src/org/python/core/PyClass.java trunk/jython/src/org/python/core/PyInstance.java Modified: trunk/jython/src/org/python/core/PyClass.java =================================================================== --- trunk/jython/src/org/python/core/PyClass.java 2009-04-05 02:32:50 UTC (rev 6162) +++ trunk/jython/src/org/python/core/PyClass.java 2009-04-05 03:18:39 UTC (rev 6163) @@ -86,12 +86,12 @@ * Setup cached references to methods where performance really counts */ private void cacheDescriptors() { - __getattr__ = lookup("__getattr__", false); - __setattr__ = lookup("__setattr__", false); - __delattr__ = lookup("__delattr__", false); - __tojava__ = lookup("__tojava__", false); - __del__ = lookup("__del__", false); - __contains__ = lookup("__contains__", false); + __getattr__ = lookup("__getattr__"); + __setattr__ = lookup("__setattr__"); + __delattr__ = lookup("__delattr__"); + __tojava__ = lookup("__tojava__"); + __del__ = lookup("__del__"); + __contains__ = lookup("__contains__"); } private static void findModule(PyObject dict) { @@ -107,28 +107,19 @@ } } - // returns [PyObject, PyClass] - PyObject[] lookupGivingClass(String name, boolean stop_at_java) { + PyObject lookup(String name) { PyObject result = __dict__.__finditem__(name); - PyClass resolvedClass = this; if (result == null && __bases__ != null) { - int n = __bases__.__len__(); - for (int i = 0; i < n; i++) { - resolvedClass = (PyClass)(__bases__.__getitem__(i)); - PyObject[] res = resolvedClass.lookupGivingClass(name, stop_at_java); - if (res[0] != null) { - return res; + for (PyObject base : __bases__.getArray()) { + result = ((PyClass)base).lookup(name); + if (result != null) { + break; } } } - return new PyObject[] { result, resolvedClass }; + return result; } - PyObject lookup(String name, boolean stop_at_java) { - PyObject[] result = lookupGivingClass(name, stop_at_java); - return result[0]; - } - @Override public PyObject fastGetDict() { return __dict__; @@ -136,12 +127,11 @@ @Override public PyObject __findattr_ex__(String name) { - PyObject[] result = lookupGivingClass(name, false); - if (result[0] == null) { + PyObject result = lookup(name); + if (result == null) { return super.__findattr_ex__(name); } - // XXX: do we need to use result[1] (wherefound) for java cases for backw comp? - return result[0].__get__(null, this); + return result.__get__(null, this); } @Override Modified: trunk/jython/src/org/python/core/PyInstance.java =================================================================== --- trunk/jython/src/org/python/core/PyInstance.java 2009-04-05 02:32:50 UTC (rev 6162) +++ trunk/jython/src/org/python/core/PyInstance.java 2009-04-05 03:18:39 UTC (rev 6163) @@ -97,14 +97,14 @@ public void __init__(PyObject[] args, String[] keywords) { // Invoke our own init function - PyObject init = instclass.lookup("__init__", true); + PyObject init = instclass.lookup("__init__"); PyObject ret = null; if (init != null) { ret = init.__call__(this, args, keywords); } if (ret == null) { if (args.length != 0) { - init = instclass.lookup("__init__", false); + init = instclass.lookup("__init__"); if (init != null) { ret = init.__call__(this, args, keywords); } else { @@ -117,34 +117,16 @@ } } - public PyObject __jfindattr__(String name) { - //System.err.println("jfinding: "+name); - return __findattr__(name, true); - } - public PyObject __findattr_ex__(String name) { - return __findattr_ex__(name, false); - } - - public PyObject __findattr__(String name, boolean stopAtJava) { - try { - return __findattr_ex__(name, stopAtJava); - } catch (PyException exc) { - if (Py.matchException(exc, Py.AttributeError)) return null; - throw exc; - } - } - - protected PyObject __findattr_ex__(String name, boolean stopAtJava) { PyObject result = ifindlocal(name); - if (result != null) + if (result != null) { return result; + } // it wasn't found in the instance, try the class - PyObject[] result2 = instclass.lookupGivingClass(name, stopAtJava); - if (result2[0] != null) - // xxx do we need to use result2[1] (wherefound) for java cases for backw comp? - return result2[0].__get__(this, instclass); - // xxx do we need to use + result = instclass.lookup(name); + if (result != null) { + return result.__get__(this, instclass); + } return ifindfunction(name); } @@ -156,8 +138,8 @@ return __dict__.__finditem__(name); } - protected PyObject ifindclass(String name, boolean stopAtJava) { - return instclass.lookup(name, stopAtJava); + protected PyObject ifindclass(String name) { + return instclass.lookup(name); } protected PyObject ifindfunction(String name) { @@ -180,7 +162,7 @@ public PyObject invoke(String name) { PyObject f = ifindlocal(name); if (f == null) { - f = ifindclass(name, false); + f = ifindclass(name); if (f != null) { if (f instanceof PyFunction) { return f.__call__(this); @@ -197,7 +179,7 @@ public PyObject invoke(String name, PyObject arg1) { PyObject f = ifindlocal(name); if (f == null) { - f = ifindclass(name, false); + f = ifindclass(name); if (f != null) { if (f instanceof PyFunction) { return f.__call__(this, arg1); @@ -214,7 +196,7 @@ public PyObject invoke(String name, PyObject arg1, PyObject arg2) { PyObject f = ifindlocal(name); if (f == null) { - f = ifindclass(name, false); + f = ifindclass(name); if (f != null) { if (f instanceof PyFunction) { return f.__call__(this, arg1, arg2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-05 02:33:04
|
Revision: 6162 http://jython.svn.sourceforge.net/jython/?rev=6162&view=rev Author: pjenvey Date: 2009-04-05 02:32:50 +0000 (Sun, 05 Apr 2009) Log Message: ----------- remove the _new.classobj hack now that PyClass __new__ does the right thing Modified Paths: -------------- trunk/jython/Lib/new.py trunk/jython/src/org/python/modules/Setup.java Removed Paths: ------------- trunk/jython/src/org/python/modules/_newmodule.java Modified: trunk/jython/Lib/new.py =================================================================== --- trunk/jython/Lib/new.py 2009-04-05 01:53:25 UTC (rev 6161) +++ trunk/jython/Lib/new.py 2009-04-05 02:32:50 UTC (rev 6162) @@ -4,10 +4,7 @@ Objects of most types can now be created by calling the type object. """ -# XXX: Hack for types.ClassType not supporting creation of new style -# classes; see org.python.modules._newmodule.classobj for more info -#from types import ClassType as classobj -from _new import classobj +from types import ClassType as classobj from types import FunctionType as function from types import InstanceType as instance from types import MethodType as instancemethod Modified: trunk/jython/src/org/python/modules/Setup.java =================================================================== --- trunk/jython/src/org/python/modules/Setup.java 2009-04-05 01:53:25 UTC (rev 6161) +++ trunk/jython/src/org/python/modules/Setup.java 2009-04-05 02:32:50 UTC (rev 6162) @@ -41,7 +41,6 @@ "_codecs", "imp", "ucnhash", - "_new:org.python.modules._newmodule", "_weakref:org.python.modules._weakref.WeakrefModule", "errno", "array:org.python.modules.ArrayModule", Deleted: trunk/jython/src/org/python/modules/_newmodule.java =================================================================== --- trunk/jython/src/org/python/modules/_newmodule.java 2009-04-05 01:53:25 UTC (rev 6161) +++ trunk/jython/src/org/python/modules/_newmodule.java 2009-04-05 02:32:50 UTC (rev 6162) @@ -1,38 +0,0 @@ -/* Copyright (c) 2001, 2003 Finn Bock, Samuele Pedroni */ -package org.python.modules; - -import org.python.core.ClassDictInit; -import org.python.core.Py; -import org.python.core.PyClass; -import org.python.core.PyObject; -import org.python.core.PyTuple; -import org.python.core.PyType; - -/** - * The internal new module; just provides a hack for new.classobj. - * - */ -public class _newmodule implements ClassDictInit { - - public static void classDictInit(PyObject dict) - { - dict.__setitem__("__name__", Py.newString("_new")); - } - - public static PyObject classobj(String name, PyTuple bases, PyObject dict) { - // XXX: Hack to return new style classes (originally from - // r4225). types.ClassType (PyClass) should be doing this - // instead, but it needs to be new style so it can return new - // style classes via __new__. When that happens we can use the - // pure python new.py completely - // XXX: This workaround can't be done in new.py (pure python) - // because the caller's stack frame would be wrong (which is - // used to determine the new class's __module__) - for (PyObject base : bases.getArray()) { - if (base instanceof PyType) { - return base.getType().__call__(Py.newString(name), bases, dict); - } - } - return Py.makeClass(name, bases.getArray(), dict); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-05 01:53:37
|
Revision: 6161 http://jython.svn.sourceforge.net/jython/?rev=6161&view=rev Author: pjenvey Date: 2009-04-05 01:53:25 +0000 (Sun, 05 Apr 2009) Log Message: ----------- convert PyClass to exposed annotations Modified Paths: -------------- trunk/jython/CoreExposed.includes trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyClass.java trunk/jython/src/org/python/modules/_newmodule.java Modified: trunk/jython/CoreExposed.includes =================================================================== --- trunk/jython/CoreExposed.includes 2009-04-05 01:15:45 UTC (rev 6160) +++ trunk/jython/CoreExposed.includes 2009-04-05 01:53:25 UTC (rev 6161) @@ -6,6 +6,7 @@ org/python/core/PyBoolean.class org/python/core/PyBuiltinCallable.class org/python/core/PyCell.class +org/python/core/PyClass.class org/python/core/PyClassMethod.class org/python/core/PyClassMethodDescr.class org/python/core/PyComplex.class Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-04-05 01:15:45 UTC (rev 6160) +++ trunk/jython/src/org/python/core/Py.java 2009-04-05 01:53:25 UTC (rev 6161) @@ -1532,8 +1532,6 @@ String.class, PyTuple.class, PyObject.class, Class.class }; - static private final PyType CLASS_TYPE = PyType.fromClass(PyClass.class); - // XXX: The following two makeClass overrides are *only* for the // old compiler, they should be removed when the newcompiler hits public static PyObject makeClass(String name, PyObject[] bases, @@ -1590,21 +1588,10 @@ if (globals != null) { metaclass = globals.__finditem__("__metaclass__"); } - } - } - - if (metaclass == null || metaclass == CLASS_TYPE) { - boolean moreGeneral = false; - for (PyObject base : bases) { - if (!(base instanceof PyClass)) { - metaclass = base.getType(); - moreGeneral = true; - break; + if (metaclass == null) { + metaclass = PyClass.TYPE; } } - if (!moreGeneral) { - return new PyClass(name, new PyTuple(bases), dict); - } } try { Modified: trunk/jython/src/org/python/core/PyClass.java =================================================================== --- trunk/jython/src/org/python/core/PyClass.java 2009-04-05 01:15:45 UTC (rev 6160) +++ trunk/jython/src/org/python/core/PyClass.java 2009-04-05 01:53:25 UTC (rev 6161) @@ -1,56 +1,91 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; +import org.python.expose.ExposedGet; +import org.python.expose.ExposedMethod; +import org.python.expose.ExposedNew; +import org.python.expose.ExposedSet; +import org.python.expose.ExposedType; + /** - * A python class. + * The classic Python class. */ +@ExposedType(name = "classobj", isBaseType = false) public class PyClass extends PyObject { - /** - * Holds the namespace for this class - */ + + public static final PyType TYPE = PyType.fromClass(PyClass.class); + + /** Holds the namespace for this class */ + @ExposedGet public PyObject __dict__; - /** - * The base classes of this class - */ + /** The base classes of this class */ + @ExposedGet public PyTuple __bases__; - /** - * The name of this class - */ + /** The name of this class */ + @ExposedGet + @ExposedSet public String __name__; - // Store these methods for performance optimization - // These are only used by PyInstance - PyObject __getattr__, __setattr__, __delattr__, __tojava__, __del__, - __contains__; + // Store these methods for performance optimization. These are only used by PyInstance + PyObject __getattr__, __setattr__, __delattr__, __tojava__, __del__, __contains__; - protected PyClass() { - super(); - } - /** - * Create a python class. - * - * @param name name of the class. - * @param bases A list of base classes. - * @param dict The class dict. Normally this dict is returned by the class - * code object. - * - * @see org.python.core.Py#makeClass(String, PyObject[], PyCode, PyObject) + * Create a new instance of a Python classic class. */ - public PyClass(String name, PyTuple bases, PyObject dict) { - __name__ = name; - __bases__ = bases; - __dict__ = dict; + private PyClass() { + super(TYPE); + } - findModule(dict); + @ExposedNew + public static PyObject classobj___new__(PyNewWrapper new_, boolean init, PyType subtype, + PyObject[] args, String[] keywords) { + ArgParser ap = new ArgParser("function", args, keywords, "name", "bases", "dict"); + PyObject name = ap.getPyObject(0); + PyObject bases = ap.getPyObject(1); + PyObject dict = ap.getPyObject(2); + return classobj___new__(name, bases, dict); + } + public static PyObject classobj___new__(PyObject name, PyObject bases, PyObject dict) { + if (!name.getType().isSubType(PyString.TYPE)) { + throw Py.TypeError("PyClass_New: name must be a string"); + } + if (!(dict instanceof PyStringMap || dict instanceof PyDictionary)) { + throw Py.TypeError("PyClass_New: dict must be a dictionary"); + } if (dict.__finditem__("__doc__") == null) { dict.__setitem__("__doc__", Py.None); } + findModule(dict); - // Setup cached references to methods where performance really counts + if (!(bases instanceof PyTuple)) { + throw Py.TypeError("PyClass_New: bases must be a tuple"); + } + PyTuple basesTuple = (PyTuple)bases; + for (PyObject base : basesTuple.getArray()) { + if (!(base instanceof PyClass)) { + if (base.getType().isCallable()) { + return base.getType().__call__(name, bases, dict); + } else { + throw Py.TypeError("PyClass_New: base must be a class"); + } + } + } + + PyClass klass = new PyClass(); + klass.__name__ = name.toString(); + klass.__bases__ = basesTuple; + klass.__dict__ = dict; + klass.cacheDescriptors(); + return klass; + } + + /** + * Setup cached references to methods where performance really counts + */ + private void cacheDescriptors() { __getattr__ = lookup("__getattr__", false); __setattr__ = lookup("__setattr__", false); __delattr__ = lookup("__delattr__", false); @@ -59,7 +94,7 @@ __contains__ = lookup("__contains__", false); } - protected void findModule(PyObject dict) { + private static void findModule(PyObject dict) { PyObject module = dict.__finditem__("__module__"); if (module == null || module == Py.None) { PyFrame f = Py.getFrame(); @@ -89,68 +124,27 @@ return new PyObject[] { result, resolvedClass }; } - public PyObject fastGetDict() { - return __dict__; - } - PyObject lookup(String name, boolean stop_at_java) { PyObject[] result = lookupGivingClass(name, stop_at_java); return result[0]; } + @Override + public PyObject fastGetDict() { + return __dict__; + } + + @Override public PyObject __findattr_ex__(String name) { - if (name == "__dict__") { - return __dict__; - } - if (name == "__name__") { - return new PyString(__name__); - } - if (name == "__bases__") { - return __bases__; - } - if (name == "__class__") { - return null; - } - PyObject[] result = lookupGivingClass(name, false); - if (result[0] == null) { return super.__findattr_ex__(name); } - // xxx do we need to use result[1] (wherefound) for java cases for backw - // comp? + // XXX: do we need to use result[1] (wherefound) for java cases for backw comp? return result[0].__get__(null, this); } - public void __setattr__(String name, PyObject value) { - if (name == "__dict__") { - if (!value.isMappingType()) - throw Py.TypeError("__dict__ must be a dictionary object"); - __dict__ = value; - return; - } - if (name == "__name__") { - if (!(value instanceof PyString)) { - throw Py.TypeError("__name__ must be a string object"); - } - __name__ = value.toString(); - return; - } - if (name == "__bases__") { - if (!(value instanceof PyTuple)) { - throw Py.TypeError("__bases__ must be a tuple object"); - } - __bases__ = (PyTuple) value; - return; - } - - __dict__.__setitem__(name, value); - } - - public void __delattr__(String name) { - __dict__.__delitem__(name); - } - + @Override public void __rawdir__(PyDictionary accum) { mergeClassDict(accum, this); } @@ -158,25 +152,28 @@ /** * Customized AttributeError for class objects. */ + @Override public void noAttributeError(String name) { throw Py.AttributeError(String.format("class %.50s has no attribute '%.400s'", __name__, name)); } + @Override + @ExposedMethod public PyObject __call__(PyObject[] args, String[] keywords) { PyInstance inst; if (__del__ == null) { inst = new PyInstance(this); } else { - // the class defined an __del__ method + // the class defined a __del__ method inst = new PyFinalizableInstance(this); } inst.__init__(args, keywords); - return inst; } /* PyClass's are compared based on __name__ */ + @Override public int __cmp__(PyObject other) { if (!(other instanceof PyClass)) { return -2; @@ -185,6 +182,7 @@ return c < 0 ? -1 : c > 0 ? 1 : 0; } + @Override public PyString __str__() { // Current CPython standard is that str(class) prints as // module.class. If the class has no module, then just the class @@ -200,6 +198,7 @@ return new PyString(smod + "." + __name__); } + @Override public String toString() { PyObject mod = __dict__.__finditem__("__module__"); String smod; @@ -215,17 +214,35 @@ if (this == superclass) { return true; } - if (this.__bases__ == null || superclass.__bases__ == null) { + if (__bases__ == null || superclass.__bases__ == null) { return false; } - PyObject[] bases = this.__bases__.getArray(); - int n = bases.length; - for (int i = 0; i < n; i++) { - PyClass c = (PyClass) bases[i]; - if (c.isSubClass(superclass)) { + for (PyObject base: __bases__.getArray()) { + if (((PyClass)base).isSubClass(superclass)) { return true; } } return false; } + + @ExposedSet(name = "__dict__") + public void setDict(PyObject value) { + if (!(value instanceof PyStringMap || value instanceof PyDictionary)) { + throw Py.TypeError("__dict__ must be a dictionary object"); + } + __dict__ = value; + } + + @ExposedSet(name = "__bases__") + public void setBases(PyTuple value) { + for (PyObject base : value.getArray()) { + if (!(base instanceof PyClass)) { + throw Py.TypeError("__bases__ items must be classes"); + } + if (((PyClass)base).isSubClass(this)) { + throw Py.TypeError("a __bases__ item causes an inheritance cycle"); + } + } + __bases__ = value; + } } Modified: trunk/jython/src/org/python/modules/_newmodule.java =================================================================== --- trunk/jython/src/org/python/modules/_newmodule.java 2009-04-05 01:15:45 UTC (rev 6160) +++ trunk/jython/src/org/python/modules/_newmodule.java 2009-04-05 01:53:25 UTC (rev 6161) @@ -33,6 +33,6 @@ return base.getType().__call__(Py.newString(name), bases, dict); } } - return new PyClass(name, bases, dict); + return Py.makeClass(name, bases.getArray(), dict); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-04-05 01:15:55
|
Revision: 6160 http://jython.svn.sourceforge.net/jython/?rev=6160&view=rev Author: zyasoft Date: 2009-04-05 01:15:45 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Creating newlist branch, to address #1026 (thread safety for lists) Added Paths: ----------- branches/newlist/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2009-04-04 15:15:23
|
Revision: 6159 http://jython.svn.sourceforge.net/jython/?rev=6159&view=rev Author: amak Date: 2009-04-04 15:15:16 +0000 (Sat, 04 Apr 2009) Log Message: ----------- Re-arranging the way that options are handled: some options are at a level different to SOL_SOCKET, namely TCP_NODELAY, which is at level IPPROTO_TCP, which is now supported. Fixes 1191: socket.IPPROTO_TCP=6 missing constant for socket module http://bugs.jython.org/issue1191 Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2009-04-04 04:11:53 UTC (rev 6158) +++ trunk/jython/Lib/socket.py 2009-04-04 15:15:16 UTC (rev 6159) @@ -159,6 +159,8 @@ SOCK_SEQPACKET = 5 # not supported SOL_SOCKET = 0xFFFF +IPPROTO_TCP = 6 +IPPROTO_UDP = 17 SO_BROADCAST = 1 SO_KEEPALIVE = 2 @@ -195,7 +197,7 @@ 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', - 'INADDR_ANY', 'INADDR_BROADCAST', + 'INADDR_ANY', 'INADDR_BROADCAST', 'IPPROTO_TCP', 'IPPROTO_UDP', 'SocketType', 'error', 'herror', 'gaierror', 'timeout', 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', 'socket', 'getaddrinfo', 'getdefaulttimeout', 'setdefaulttimeout', @@ -222,9 +224,9 @@ self._timeout_millis = int(timeout*1000) self.jsocket.setSoTimeout(self._timeout_millis) - def getsockopt(self, option): - if self.options.has_key(option): - result = getattr(self.jsocket, "get%s" % self.options[option])() + def getsockopt(self, level, option): + if self.options.has_key( (level, option) ): + result = getattr(self.jsocket, "get%s" % self.options[ (level, option) ])() if option == SO_LINGER: if result == -1: enabled, linger_time = 0, 0 @@ -233,17 +235,17 @@ return struct.pack('ii', enabled, linger_time) return result else: - raise error(errno.ENOPROTOOPT, "Option not supported on socket(%s): %d" % (str(self.jsocket), option)) + raise error(errno.ENOPROTOOPT, "Level %d option not supported on socket(%s): %d" % (level, str(self.jsocket), option)) - def setsockopt(self, option, value): - if self.options.has_key(option): + def setsockopt(self, level, option, value): + if self.options.has_key( (level, option) ): if option == SO_LINGER: values = struct.unpack('ii', value) self.jsocket.setSoLinger(*values) else: - getattr(self.jsocket, "set%s" % self.options[option])(value) + getattr(self.jsocket, "set%s" % self.options[ (level, option) ])(value) else: - raise error(errno.ENOPROTOOPT, "Option not supported on socket(%s): %d" % (str(self.jsocket), option)) + raise error(errno.ENOPROTOOPT, "Level %d option not supported on socket(%s): %d" % (level, str(self.jsocket), option)) def close(self): self.jsocket.close() @@ -256,15 +258,15 @@ class _client_socket_impl(_nio_impl): - options = { - SO_KEEPALIVE: 'KeepAlive', - SO_LINGER: 'SoLinger', - SO_OOBINLINE: 'OOBInline', - SO_RCVBUF: 'ReceiveBufferSize', - SO_REUSEADDR: 'ReuseAddress', - SO_SNDBUF: 'SendBufferSize', - SO_TIMEOUT: 'SoTimeout', - TCP_NODELAY: 'TcpNoDelay', + options = { + (SOL_SOCKET, SO_KEEPALIVE): 'KeepAlive', + (SOL_SOCKET, SO_LINGER): 'SoLinger', + (SOL_SOCKET, SO_OOBINLINE): 'OOBInline', + (SOL_SOCKET, SO_RCVBUF): 'ReceiveBufferSize', + (SOL_SOCKET, SO_REUSEADDR): 'ReuseAddress', + (SOL_SOCKET, SO_SNDBUF): 'SendBufferSize', + (SOL_SOCKET, SO_TIMEOUT): 'SoTimeout', + (IPPROTO_TCP, TCP_NODELAY): 'TcpNoDelay', } def __init__(self, socket=None): @@ -332,10 +334,10 @@ class _server_socket_impl(_nio_impl): - options = { - SO_RCVBUF: 'ReceiveBufferSize', - SO_REUSEADDR: 'ReuseAddress', - SO_TIMEOUT: 'SoTimeout', + options = { + (SOL_SOCKET, SO_RCVBUF): 'ReceiveBufferSize', + (SOL_SOCKET, SO_REUSEADDR): 'ReuseAddress', + (SOL_SOCKET, SO_TIMEOUT): 'SoTimeout', } def __init__(self, host, port, backlog, reuse_addr): @@ -370,12 +372,12 @@ class _datagram_socket_impl(_nio_impl): - options = { - SO_BROADCAST: 'Broadcast', - SO_RCVBUF: 'ReceiveBufferSize', - SO_REUSEADDR: 'ReuseAddress', - SO_SNDBUF: 'SendBufferSize', - SO_TIMEOUT: 'SoTimeout', + options = { + (SOL_SOCKET, SO_BROADCAST): 'Broadcast', + (SOL_SOCKET, SO_RCVBUF): 'ReceiveBufferSize', + (SOL_SOCKET, SO_REUSEADDR): 'ReuseAddress', + (SOL_SOCKET, SO_SNDBUF): 'SendBufferSize', + (SOL_SOCKET, SO_TIMEOUT): 'SoTimeout', } def __init__(self, port=None, address=None, reuse_addr=0): @@ -542,13 +544,16 @@ # Same situation as above raise NotImplementedError("getprotobyname not yet supported on jython.") -def _realsocket(family = AF_INET, type = SOCK_STREAM, flags=0): - assert family == AF_INET - assert type in (SOCK_DGRAM, SOCK_STREAM) - assert flags == 0 +def _realsocket(family = AF_INET, type = SOCK_STREAM, protocol=0): + assert family == AF_INET, "Only AF_INET sockets are currently supported on jython" + assert type in (SOCK_DGRAM, SOCK_STREAM), "Only SOCK_STREAM and SOCK_DGRAM sockets are currently supported on jython" if type == SOCK_STREAM: + if protocol != 0: + assert protocol == IPPROTO_TCP, "Only IPPROTO_TCP supported on SOCK_STREAM sockets" return _tcpsocket() else: + if protocol != 0: + assert protocol == IPPROTO_UDP, "Only IPPROTO_UDP supported on SOCK_DGRAM sockets" return _udpsocket() def getaddrinfo(host, port, family=AF_INET, socktype=None, proto=0, flags=None): @@ -645,7 +650,7 @@ if self.timeout is not None: self.mode = MODE_TIMEOUT self.pending_options = { - SO_REUSEADDR: 0, + (SOL_SOCKET, SO_REUSEADDR): 0, } def gettimeout(self): @@ -674,22 +679,20 @@ return self.mode == MODE_BLOCKING def setsockopt(self, level, optname, value): - if level != SOL_SOCKET: return try: if self.sock_impl: - self.sock_impl.setsockopt(optname, value) + self.sock_impl.setsockopt(level, optname, value) else: - self.pending_options[optname] = value + self.pending_options[ (level, optname) ] = value except java.lang.Exception, jlx: raise _map_exception(jlx) def getsockopt(self, level, optname): - if level != SOL_SOCKET: return try: if self.sock_impl: - return self.sock_impl.getsockopt(optname) + return self.sock_impl.getsockopt(level, optname) else: - return self.pending_options.get(optname, None) + return self.pending_options.get( (level, optname), None) except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -713,9 +716,9 @@ assert self.mode in _permitted_modes if self.sock_impl: self.sock_impl.config(self.mode, self.timeout) - for k in self.pending_options.keys(): - if k != SO_REUSEADDR: - self.sock_impl.setsockopt(k, self.pending_options[k]) + for level, optname in self.pending_options.keys(): + if optname != SO_REUSEADDR: + self.sock_impl.setsockopt(level, optname, self.pending_options[ (level, optname) ]) def getchannel(self): if not self.sock_impl: @@ -775,7 +778,7 @@ host, port = _unpack_address_tuple(self.local_addr) else: host, port = "", 0 - self.sock_impl = _server_socket_impl(host, port, backlog, self.pending_options[SO_REUSEADDR]) + self.sock_impl = _server_socket_impl(host, port, backlog, self.pending_options[ (SOL_SOCKET, SO_REUSEADDR) ]) self._config() except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -790,7 +793,7 @@ if not new_sock: raise would_block_error() cliconn = _tcpsocket() - cliconn.pending_options[SO_REUSEADDR] = new_sock.jsocket.getReuseAddress() + cliconn.pending_options[ (SOL_SOCKET, SO_REUSEADDR) ] = new_sock.jsocket.getReuseAddress() cliconn.sock_impl = new_sock cliconn._setup() return cliconn, new_sock.getpeername() @@ -810,7 +813,7 @@ self.sock_impl = _client_socket_impl() if self.local_addr: # Has the socket been bound to a local address? bind_host, bind_port = _unpack_address_tuple(self.local_addr) - self.sock_impl.bind(bind_host, bind_port, self.pending_options[SO_REUSEADDR]) + self.sock_impl.bind(bind_host, bind_port, self.pending_options[ (SOL_SOCKET, SO_REUSEADDR) ]) self._config() # Configure timeouts, etc, now that the socket exists self.sock_impl.connect(host, port) except java.lang.Exception, jlx: @@ -925,7 +928,7 @@ if host == "": host = INADDR_ANY host_address = java.net.InetAddress.getByName(host) - self.sock_impl = _datagram_socket_impl(port, host_address, self.pending_options[SO_REUSEADDR]) + self.sock_impl = _datagram_socket_impl(port, host_address, self.pending_options[ (SOL_SOCKET, SO_REUSEADDR) ]) self._config() except java.lang.Exception, jlx: raise _map_exception(jlx) Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2009-04-04 04:11:53 UTC (rev 6158) +++ trunk/jython/Lib/test/test_socket.py 2009-04-04 15:15:16 UTC (rev 6159) @@ -528,29 +528,29 @@ class TestSocketOptions(unittest.TestCase): - def setUp(self): + def setUp(self): self.test_udp = self.test_tcp_client = self.test_tcp_server = 0 - def _testSetAndGetOption(self, sock, option, values): + def _testSetAndGetOption(self, sock, level, option, values): for expected_value in values: - sock.setsockopt(socket.SOL_SOCKET, option, expected_value) - retrieved_value = sock.getsockopt(socket.SOL_SOCKET, option) + sock.setsockopt(level, option, expected_value) + retrieved_value = sock.getsockopt(level, option) self.failUnlessEqual(retrieved_value, expected_value, \ - "Retrieved option(%s) value %s != %s(value set)" % (option, retrieved_value, expected_value)) + "Retrieved option(%s, %s) value %s != %s(value set)" % (level, option, retrieved_value, expected_value)) - def _testUDPOption(self, option, values): + def _testUDPOption(self, level, option, values): try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self._testSetAndGetOption(sock, option, values) + self._testSetAndGetOption(sock, level, option, values) # now bind the socket i.e. cause the implementation socket to be created sock.bind( (HOST, PORT) ) - self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], \ - "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1]) ) - self._testSetAndGetOption(sock, option, values) + self.failUnlessEqual(sock.getsockopt(level, option), values[-1], \ + "Option value '(%s, %s)'='%s' did not propagate to implementation socket" % (level, option, values[-1]) ) + self._testSetAndGetOption(sock, level, option, values) finally: sock.close() - def _testTCPClientOption(self, option, values): + def _testTCPClientOption(self, level, option, values): sock = None try: # First listen on a server socket, so that the connection won't be refused. @@ -559,7 +559,7 @@ server_sock.listen(50) # Now do the tests sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._testSetAndGetOption(sock, option, values) + self._testSetAndGetOption(sock, level, option, values) # now connect the socket i.e. cause the implementation socket to be created # First bind, so that the SO_REUSEADDR setting propagates sock.bind( (HOST, PORT+1) ) @@ -571,39 +571,39 @@ # establishing a connection. seems it will be *at least* # the values we test (which are rather small) on # BSDs. may need to relax this on other platforms also - self.assert_(sock.getsockopt(socket.SOL_SOCKET, option) >= values[-1], msg) + self.assert_(sock.getsockopt(level, option) >= values[-1], msg) else: - self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], msg) - self._testSetAndGetOption(sock, option, values) + self.failUnlessEqual(sock.getsockopt(level, option), values[-1], msg) + self._testSetAndGetOption(sock, level, option, values) finally: server_sock.close() if sock: sock.close() - def _testTCPServerOption(self, option, values): + def _testTCPServerOption(self, level, option, values): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self._testSetAndGetOption(sock, option, values) + self._testSetAndGetOption(sock, level, option, values) # now bind and listen on the socket i.e. cause the implementation socket to be created sock.bind( (HOST, PORT) ) sock.listen(50) - self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], \ - "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1])) - self._testSetAndGetOption(sock, option, values) + self.failUnlessEqual(sock.getsockopt(level, option), values[-1], \ + "Option value '(%s,%s)'='%s' did not propagate to implementation socket" % (level, option, values[-1])) + self._testSetAndGetOption(sock, level, option, values) finally: sock.close() - def _testOption(self, option, values): + def _testOption(self, level, option, values): for flag, func in [ (self.test_udp, self._testUDPOption), (self.test_tcp_server, self._testTCPServerOption), (self.test_tcp_client, self._testTCPClientOption), ]: if flag: - func(option, values) + func(level, option, values) else: try: - func(option, values) + func(level, option, values) except socket.error, se: self.failUnlessEqual(se[0], errno.ENOPROTOOPT, "Wrong errno from unsupported option exception: %d" % se[0]) except Exception, x: @@ -613,50 +613,50 @@ class TestSupportedOptions(TestSocketOptions): - def testSO_BROADCAST(self): + def testSO_BROADCAST(self): self.test_udp = 1 - self._testOption(socket.SO_BROADCAST, [0, 1]) + self._testOption(socket.SOL_SOCKET, socket.SO_BROADCAST, [0, 1]) def testSO_KEEPALIVE(self): self.test_tcp_client = 1 - self._testOption(socket.SO_KEEPALIVE, [0, 1]) + self._testOption(socket.SOL_SOCKET, socket.SO_KEEPALIVE, [0, 1]) def testSO_LINGER(self): self.test_tcp_client = 1 off = struct.pack('ii', 0, 0) on_2_seconds = struct.pack('ii', 1, 2) - self._testOption(socket.SO_LINGER, [off, on_2_seconds]) + self._testOption(socket.SOL_SOCKET, socket.SO_LINGER, [off, on_2_seconds]) def testSO_OOBINLINE(self): self.test_tcp_client = 1 - self._testOption(socket.SO_OOBINLINE, [0, 1]) + self._testOption(socket.SOL_SOCKET, socket.SO_OOBINLINE, [0, 1]) def testSO_RCVBUF(self): self.test_udp = 1 self.test_tcp_client = 1 self.test_tcp_server = 1 - self._testOption(socket.SO_RCVBUF, [1024, 4096, 16384]) + self._testOption(socket.SOL_SOCKET, socket.SO_RCVBUF, [1024, 4096, 16384]) def testSO_REUSEADDR(self): self.test_udp = 1 self.test_tcp_client = 1 self.test_tcp_server = 1 - self._testOption(socket.SO_REUSEADDR, [0, 1]) + self._testOption(socket.SOL_SOCKET, socket.SO_REUSEADDR, [0, 1]) def testSO_SNDBUF(self): self.test_udp = 1 self.test_tcp_client = 1 - self._testOption(socket.SO_SNDBUF, [1024, 4096, 16384]) + self._testOption(socket.SOL_SOCKET, socket.SO_SNDBUF, [1024, 4096, 16384]) def testSO_TIMEOUT(self): self.test_udp = 1 self.test_tcp_client = 1 self.test_tcp_server = 1 - self._testOption(socket.SO_TIMEOUT, [0, 1, 1000]) + self._testOption(socket.SOL_SOCKET, socket.SO_TIMEOUT, [0, 1, 1000]) def testTCP_NODELAY(self): self.test_tcp_client = 1 - self._testOption(socket.TCP_NODELAY, [0, 1]) + self._testOption(socket.IPPROTO_TCP, socket.TCP_NODELAY, [0, 1]) class TestUnsupportedOptions(TestSocketOptions): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-04 04:12:01
|
Revision: 6158 http://jython.svn.sourceforge.net/jython/?rev=6158&view=rev Author: pjenvey Date: 2009-04-04 04:11:53 +0000 (Sat, 04 Apr 2009) Log Message: ----------- move to unicode tests Modified Paths: -------------- trunk/jython/Lib/test/test_str_jy.py trunk/jython/Lib/test/test_unicode_jy.py Modified: trunk/jython/Lib/test/test_str_jy.py =================================================================== --- trunk/jython/Lib/test/test_str_jy.py 2009-04-04 04:11:13 UTC (rev 6157) +++ trunk/jython/Lib/test/test_str_jy.py 2009-04-04 04:11:53 UTC (rev 6158) @@ -92,14 +92,7 @@ # But, args found before the first unicode should not be __unicode__'d self.assertEquals("%s %s %s" % (S(), u"bar", S()), u"str bar unicode") - def test_non_ascii_unicode_mod_str(self): - # Regression test for a problem on the formatting logic: when no unicode - # args were found, Jython stored the resulting buffer on a PyString, - # decoding it later to make a PyUnicode. That crashed when the left side - # of % was a unicode containing non-ascii chars - self.assertEquals(u"\u00e7%s" % "foo", u"\u00e7foo") - class DisplayTest(unittest.TestCase): def test_str_and_repr(self): Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 04:11:13 UTC (rev 6157) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 04:11:53 UTC (rev 6158) @@ -120,7 +120,14 @@ return key u'%(foo)s' % EnsureUnicode() + def test_non_ascii_unicode_mod_str(self): + # Regression test for a problem on the formatting logic: when no unicode + # args were found, Jython stored the resulting buffer on a PyString, + # decoding it later to make a PyUnicode. That crashed when the left side + # of % was a unicode containing non-ascii chars + self.assertEquals(u"\u00e7%s" % "foo", u"\u00e7foo") + def test_main(): test_support.run_unittest(UnicodeTestCase, UnicodeFormatTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-04 04:11:19
|
Revision: 6157 http://jython.svn.sourceforge.net/jython/?rev=6157&view=rev Author: pjenvey Date: 2009-04-04 04:11:13 +0000 (Sat, 04 Apr 2009) Log Message: ----------- fix unicode format mappings to use unicode keys Modified Paths: -------------- trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/src/org/python/core/PyString.java Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 01:16:56 UTC (rev 6156) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-04-04 04:11:13 UTC (rev 6157) @@ -109,8 +109,21 @@ self.assertEquals('\xe2\x82\xac', encoded_euro) self.assertEquals(EURO_SIGN, encoded_euro.decode('utf-8')) + +class UnicodeFormatTestCase(unittest.TestCase): + + def test_unicode_mapping(self): + assertTrue = self.assertTrue + class EnsureUnicode(dict): + def __missing__(self, key): + assertTrue(isinstance(key, unicode)) + return key + u'%(foo)s' % EnsureUnicode() + + def test_main(): - test_support.run_unittest(UnicodeTestCase) + test_support.run_unittest(UnicodeTestCase, + UnicodeFormatTestCase) if __name__ == "__main__": Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-04-04 01:16:56 UTC (rev 6156) +++ trunk/jython/src/org/python/core/PyString.java 2009-04-04 04:11:13 UTC (rev 6157) @@ -2852,7 +2852,7 @@ parens++; } String tmp = format.substring(keyStart, index-1); - this.args = dict.__getitem__(new PyString(tmp)); + this.args = dict.__getitem__(needUnicode ? new PyUnicode(tmp) : new PyString(tmp)); } else { push(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-04 01:17:09
|
Revision: 6156 http://jython.svn.sourceforge.net/jython/?rev=6156&view=rev Author: pjenvey Date: 2009-04-04 01:16:56 +0000 (Sat, 04 Apr 2009) Log Message: ----------- more robust handling of pickle loading errors Modified Paths: -------------- trunk/jython/src/org/python/modules/cPickle.java Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2009-04-03 16:43:24 UTC (rev 6155) +++ trunk/jython/src/org/python/modules/cPickle.java 2009-04-04 01:16:56 UTC (rev 6156) @@ -1670,6 +1670,9 @@ case LONG4: load_bin_long(4); break; case STOP: return load_stop(); + default: + throw new PyException(UnpicklingError, + String.format("invalid load key, '%s'.", key)); } } } @@ -2150,40 +2153,43 @@ } private void load_build() { - PyObject value = pop(); + PyObject state = pop(); PyObject inst = peek(); PyObject setstate = inst.__findattr__("__setstate__"); - if(setstate == null) { - PyObject slotstate = null; - // A default __setstate__. First see whether state - // embeds a slot state dict too (a proto 2 addition). - if (value instanceof PyTuple && value.__len__() == 2) { - PyObject temp = value; - value = temp.__getitem__(0); - slotstate = temp.__getitem__(1); - } + if (setstate != null) { + // The explicit __setstate__ is responsible for everything. + setstate.__call__(state); + return; + } - PyObject dict; - if(inst instanceof PyInstance) { - dict = ((PyInstance)inst).__dict__; - } else { - dict = inst.getDict(); + // A default __setstate__. First see whether state embeds a slot state dict + // too (a proto 2 addition). + PyObject slotstate = null; + if (state instanceof PyTuple && state.__len__() == 2) { + PyObject temp = state; + state = temp.__getitem__(0); + slotstate = temp.__getitem__(1); + } + + if (state != Py.None) { + if (!(state instanceof PyDictionary)) { + throw new PyException(UnpicklingError, "state is not a dictionary"); } - dict.__findattr__("update").__call__(value); + PyObject dict = inst.__getattr__("__dict__"); + for (PyObject item : ((PyDictionary)state).iteritems().asIterable()) { + dict.__setitem__(item.__getitem__(0), item.__getitem__(1)); + } + } - // Also set instance attributes from the slotstate - // dict (if any). - if (slotstate != null) { - if (!(slotstate instanceof PyDictionary)) { - throw new PyException(UnpicklingError, "slot state is not a dictionary"); - } - for (PyObject item : ((PyDictionary)slotstate).iteritems().asIterable()) { - inst.__setattr__(PyObject.asName(item.__getitem__(0)), - item.__getitem__(1)); - } + // Also set instance attributes from the slotstate dict (if any). + if (slotstate != null) { + if (!(slotstate instanceof PyDictionary)) { + throw new PyException(UnpicklingError, "slot state is not a dictionary"); } - } else { - setstate.__call__(value); + for (PyObject item : ((PyDictionary)slotstate).iteritems().asIterable()) { + inst.__setattr__(PyObject.asName(item.__getitem__(0)), + item.__getitem__(1)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 16:43:34
|
Revision: 6155 http://jython.svn.sourceforge.net/jython/?rev=6155&view=rev Author: pjenvey Date: 2009-04-03 16:43:24 +0000 (Fri, 03 Apr 2009) Log Message: ----------- bump magic for r6135/6142 changes Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-04-03 06:06:39 UTC (rev 6154) +++ trunk/jython/src/org/python/core/imp.java 2009-04-03 16:43:24 UTC (rev 6155) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 18; + public static final int APIVersion = 19; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 06:06:53
|
Revision: 6154 http://jython.svn.sourceforge.net/jython/?rev=6154&view=rev Author: pjenvey Date: 2009-04-03 06:06:39 +0000 (Fri, 03 Apr 2009) Log Message: ----------- o rewrite popen2/os.{popen,system} to use subprocess. fixes popen2 deadlocking o bump test_communicate_pipe_buf to a larger size as per #1124's test o deprecate javashell which is no longer used thanks Pekka Klarck fixes #1124 Modified Paths: -------------- trunk/jython/Lib/javashell.py trunk/jython/Lib/os.py trunk/jython/Lib/popen2.py trunk/jython/Lib/test/test_subprocess.py Modified: trunk/jython/Lib/javashell.py =================================================================== --- trunk/jython/Lib/javashell.py 2009-04-03 06:02:36 UTC (rev 6153) +++ trunk/jython/Lib/javashell.py 2009-04-03 06:06:39 UTC (rev 6154) @@ -20,8 +20,11 @@ import subprocess import sys import types +import warnings +warnings.warn('The javashell module is deprecated. Use the subprocess module.', + DeprecationWarning, 2) -__all__ = [ "shellexecute", "environ", "putenv", "getenv" ] +__all__ = ["shellexecute"] def __warn( *args ): print " ".join( [str( arg ) for arg in args ]) Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-04-03 06:02:36 UTC (rev 6153) +++ trunk/jython/Lib/os.py 2009-04-03 06:06:39 UTC (rev 6154) @@ -727,27 +727,28 @@ except: raise OSError(errno.EBADF, strerror(errno.EBADF)) -# Provide lazy popen*, and system objects -# Do these lazily, as most jython programs don't need them, -# and they are very expensive to initialize - -def system( *args, **kwargs ): +def system(command): """system(command) -> exit_status Execute the command (a string) in a subshell. """ - # allow lazy import of popen2 and javashell - import popen2 - return popen2.system( *args, **kwargs ) + import subprocess + return subprocess.call(command, shell=True) -def popen( *args, **kwargs ): +def popen(command, mode='r', bufsize=-1): """popen(command [, mode='r' [, bufsize]]) -> pipe Open a pipe to/from a command returning a file object. """ - # allow lazy import of popen2 and javashell - import popen2 - return popen2.popen( *args, **kwargs ) + import subprocess + if mode == 'r': + return subprocess.Popen(command, bufsize=bufsize, shell=True, + stdout=subprocess.PIPE).stdout + elif mode == 'w': + return subprocess.Popen(command, bufsize=bufsize, shell=True, + stdin=subprocess.PIPE).stdin + else: + raise OSError(errno.EINVAL, strerror(errno.EINVAL)) # os module versions of the popen# methods have different return value # order than popen2 functions Modified: trunk/jython/Lib/popen2.py =================================================================== --- trunk/jython/Lib/popen2.py 2009-04-03 06:02:36 UTC (rev 6153) +++ trunk/jython/Lib/popen2.py 2009-04-03 06:06:39 UTC (rev 6154) @@ -7,27 +7,15 @@ """ import os +import subprocess import sys __all__ = ["popen2", "popen3", "popen4"] -try: - MAXFD = os.sysconf('SC_OPEN_MAX') -except (AttributeError, ValueError): - MAXFD = 256 +MAXFD = subprocess.MAXFD +_active = subprocess._active +_cleanup = subprocess._cleanup -_active = [] - -def _cleanup(): - for inst in _active[:]: - if inst.poll(_deadstate=sys.maxint) >= 0: - try: - _active.remove(inst) - except ValueError: - # This can happen if two threads create a new Popen instance. - # It's harmless that it was already removed, so ignore. - pass - class Popen3: """Class representing a child process. Normally instances are created by the factory functions popen2() and popen3().""" @@ -44,73 +32,36 @@ process. The default is false. If the 'bufsize' parameter is specified, it specifies the size of the I/O buffers to/from the child process.""" - _cleanup() + stderr = subprocess.PIPE if capturestderr else None + PIPE = subprocess.PIPE + self._popen = subprocess.Popen(cmd, bufsize=bufsize, shell=True, + stdin=PIPE, stdout=PIPE, stderr=stderr) + self._setup(cmd) + + def _setup(self, cmd): + """Setup the Popen attributes.""" self.cmd = cmd - p2cread, p2cwrite = os.pipe() - c2pread, c2pwrite = os.pipe() - if capturestderr: - errout, errin = os.pipe() - self.pid = os.fork() - if self.pid == 0: - # Child - os.dup2(p2cread, 0) - os.dup2(c2pwrite, 1) - if capturestderr: - os.dup2(errin, 2) - self._run_child(cmd) - os.close(p2cread) - self.tochild = os.fdopen(p2cwrite, 'w', bufsize) - os.close(c2pwrite) - self.fromchild = os.fdopen(c2pread, 'r', bufsize) - if capturestderr: - os.close(errin) - self.childerr = os.fdopen(errout, 'r', bufsize) - else: - self.childerr = None + self.pid = self._popen.pid + self.tochild = self._popen.stdin + self.fromchild = self._popen.stdout + self.childerr = self._popen.stderr def __del__(self): - # In case the child hasn't been waited on, check if it's done. - self.poll(_deadstate=sys.maxint) - if self.sts < 0: - if _active is not None: - # Child is still running, keep us alive until we can wait on it. - _active.append(self) + self._popen.__del__() - def _run_child(self, cmd): - if isinstance(cmd, basestring): - cmd = ['/bin/sh', '-c', cmd] - for i in xrange(3, MAXFD): - try: - os.close(i) - except OSError: - pass - try: - os.execvp(cmd[0], cmd) - finally: - os._exit(1) - def poll(self, _deadstate=None): """Return the exit status of the child process if it has finished, or -1 if it hasn't finished yet.""" if self.sts < 0: - try: - pid, sts = os.waitpid(self.pid, os.WNOHANG) - # pid will be 0 if self.pid hasn't terminated - if pid == self.pid: - self.sts = sts - except os.error: - if _deadstate is not None: - self.sts = _deadstate + result = self._popen.poll(_deadstate) + if result is not None: + self.sts = result return self.sts def wait(self): """Wait for and return the exit status of the child process.""" if self.sts < 0: - pid, sts = os.waitpid(self.pid, 0) - # This used to be a test, but it is believed to be - # always true, so I changed it to an assertion - mvl - assert pid == self.pid - self.sts = sts + self.sts = self._popen.wait() return self.sts @@ -118,21 +69,11 @@ childerr = None def __init__(self, cmd, bufsize=-1): - _cleanup() - self.cmd = cmd - p2cread, p2cwrite = os.pipe() - c2pread, c2pwrite = os.pipe() - self.pid = os.fork() - if self.pid == 0: - # Child - os.dup2(p2cread, 0) - os.dup2(c2pwrite, 1) - os.dup2(c2pwrite, 2) - self._run_child(cmd) - os.close(p2cread) - self.tochild = os.fdopen(p2cwrite, 'w', bufsize) - os.close(c2pwrite) - self.fromchild = os.fdopen(c2pread, 'r', bufsize) + PIPE = subprocess.PIPE + self._popen = subprocess.Popen(cmd, bufsize=bufsize, shell=True, + stdin=PIPE, stdout=PIPE, + stderr=subprocess.STDOUT) + self._setup(cmd) if sys.platform[:3] == "win" or sys.platform == "os2emx": @@ -207,7 +148,7 @@ assert not _active, "Active pipes when test starts " + repr([c.cmd for c in _active]) cmd = "cat" teststr = "ab cd\n" - if os.name == "nt": + if os.name in ("nt", "java"): cmd = "more" # "more" doesn't act the same way across Windows flavors, # sometimes adding an extra newline at the start or the Modified: trunk/jython/Lib/test/test_subprocess.py =================================================================== --- trunk/jython/Lib/test/test_subprocess.py 2009-04-03 06:02:36 UTC (rev 6153) +++ trunk/jython/Lib/test/test_subprocess.py 2009-04-03 06:06:39 UTC (rev 6154) @@ -323,8 +323,10 @@ # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if # communicate() does not work properly. - if mswindows or jython: + if mswindows: pipe_buf = 512 + elif jython: + pipe_buf = 16384 else: x, y = os.pipe() pipe_buf = os.fpathconf(x, "PC_PIPE_BUF") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 06:02:46
|
Revision: 6153 http://jython.svn.sourceforge.net/jython/?rev=6153&view=rev Author: pjenvey Date: 2009-04-03 06:02:36 +0000 (Fri, 03 Apr 2009) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/popen2.py@50759 Modified Paths: -------------- trunk/jython/Lib/popen2.py Modified: trunk/jython/Lib/popen2.py =================================================================== --- trunk/jython/Lib/popen2.py 2009-04-03 05:54:58 UTC (rev 6152) +++ trunk/jython/Lib/popen2.py 2009-04-03 06:02:36 UTC (rev 6153) @@ -1,269 +1,213 @@ -""" -popen2.py +"""Spawn a command with pipes to its stdin, stdout, and optionally stderr. -Implement popen2 module functionality for Jython. - -Note that the popen* methods in this module follow the return value -ordering of the Python popen2.popen* methods: - - fromChild, toChild = popen2.popen2(...) - fromChild, toChild, errorFromChild = popen2.popen3(...) - fromChildInclError, toChild = popen2.popen4(...) - -The os.popen* methods are more natural as follows: - - toChild, fromChild = os.popen2(...) - toChild, fromChild, errorFromChild = os.popen3(...) - toChild, fromChildInclError = os.popen4(...) - -The Popen3 and Popen4 classes allow users to poll() or wait() for -child processes to terminate. +The normal os.popen(cmd, mode) call spawns a shell command and provides a +file interface to just the input or output of the process depending on +whether mode is 'r' or 'w'. This module provides the functions popen2(cmd) +and popen3(cmd) which return two or three pipes to the spawned command. """ -import jarray -from java.lang import System -from java.util import Vector -from java.io import BufferedOutputStream -from java.io import BufferedInputStream -from java.io import PipedOutputStream -from java.io import PipedInputStream -from javashell import shellexecute -from org.python.core.util import FileUtil +import os +import sys +__all__ = ["popen2", "popen3", "popen4"] -__all__ = ["popen", "popen2", "popen3", "popen4", "Popen3", "Popen4"] +try: + MAXFD = os.sysconf('SC_OPEN_MAX') +except (AttributeError, ValueError): + MAXFD = 256 _active = [] def _cleanup(): - """For CPython compatibility""" - pass + for inst in _active[:]: + if inst.poll(_deadstate=sys.maxint) >= 0: + try: + _active.remove(inst) + except ValueError: + # This can happen if two threads create a new Popen instance. + # It's harmless that it was already removed, so ignore. + pass -class _ProcessFile: - """Python file object that returns the process exit status from - the close method. - """ - def __init__(self, stream, process, name): - self._file = FileUtil.wrap(stream, 0) - self._process = process - - def __getattr__(self, name): - return getattr(self._file, name) - - def __repr__(self): - return `self._file` - - def close(self): - self._file.close() - return self._process.waitFor() or None - class Popen3: """Class representing a child process. Normally instances are created by the factory functions popen2() and popen3().""" - sts = -1 # Child not completed yet - childWaiter = None - count = 0 - - def __init__(self, cmd, capturestderr=0, bufsize=-1): + sts = -1 # Child not completed yet + + def __init__(self, cmd, capturestderr=False, bufsize=-1): """The parameter 'cmd' is the shell command to execute in a - sub-process. Can be either a sequence of executable - and arguments, or a shell command. - The 'capturestderr' flag, if true, specifies that - the object should capture standard error output of the child process. - The default is false. If the 'bufsize' parameter is specified, it - specifies the size of the I/O buffers to/from the child process. - """ - self.process = shellexecute( cmd ) - self._tochild = self.process.getOutputStream() - self._fromchild = self.process.getInputStream() + sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments + will be passed directly to the program without shell intervention (as + with os.spawnv()). If 'cmd' is a string it will be passed to the shell + (as with os.system()). The 'capturestderr' flag, if true, specifies + that the object should capture standard error output of the child + process. The default is false. If the 'bufsize' parameter is + specified, it specifies the size of the I/O buffers to/from the child + process.""" + _cleanup() + self.cmd = cmd + p2cread, p2cwrite = os.pipe() + c2pread, c2pwrite = os.pipe() if capturestderr: - self._childerr = self.process.getErrorStream() + errout, errin = os.pipe() + self.pid = os.fork() + if self.pid == 0: + # Child + os.dup2(p2cread, 0) + os.dup2(c2pwrite, 1) + if capturestderr: + os.dup2(errin, 2) + self._run_child(cmd) + os.close(p2cread) + self.tochild = os.fdopen(p2cwrite, 'w', bufsize) + os.close(c2pwrite) + self.fromchild = os.fdopen(c2pread, 'r', bufsize) + if capturestderr: + os.close(errin) + self.childerr = os.fdopen(errout, 'r', bufsize) else: - self._childerr = None - import threading - self.childWaiterLock = threading.Lock() + self.childerr = None - if bufsize > 0: - self._tochild = BufferedOutputStream( self._tochild, bufsize ) - self._fromchild = BufferedInputStream( self._fromchild, bufsize ) - if self._childerr: - self._childerr = BufferedInputStream( - self._childerr, - bufsize - ) - - self.tochild = FileUtil.wrap(self._tochild, 0) - self.fromchild = FileUtil.wrap(self._fromchild, 0) - if self._childerr: - self.childerr = FileUtil.wrap(self._childerr, 0) + def __del__(self): + # In case the child hasn't been waited on, check if it's done. + self.poll(_deadstate=sys.maxint) + if self.sts < 0: + if _active is not None: + # Child is still running, keep us alive until we can wait on it. + _active.append(self) - def _startChildWaiter(self): - """Start a subthread that waits for the child process to exit.""" - self.childWaiterLock.acquire() + def _run_child(self, cmd): + if isinstance(cmd, basestring): + cmd = ['/bin/sh', '-c', cmd] + for i in xrange(3, MAXFD): + try: + os.close(i) + except OSError: + pass try: - if not self.childWaiter: - import threading - self.childWaiter = threading.Thread( - target=self.wait, - name="ChildWaiter %s" % self.process, - args=() - ) - self.childWaiter.setDaemon( 1 ) - self.childWaiter.start() + os.execvp(cmd[0], cmd) finally: - self.childWaiterLock.release() + os._exit(1) - def poll(self): + def poll(self, _deadstate=None): """Return the exit status of the child process if it has finished, or -1 if it hasn't finished yet.""" - if self.sts < 0 and not self.childWaiter: - self._startChildWaiter() - self.childWaiter.join( .1 ) + if self.sts < 0: + try: + pid, sts = os.waitpid(self.pid, os.WNOHANG) + # pid will be 0 if self.pid hasn't terminated + if pid == self.pid: + self.sts = sts + except os.error: + if _deadstate is not None: + self.sts = _deadstate return self.sts def wait(self): """Wait for and return the exit status of the child process.""" - self.sts = self.process.waitFor() - # some processes won't terminate until tochild stream is - # closed, but that's really the responsibility of the caller + if self.sts < 0: + pid, sts = os.waitpid(self.pid, 0) + # This used to be a test, but it is believed to be + # always true, so I changed it to an assertion - mvl + assert pid == self.pid + self.sts = sts return self.sts -def _makeReaderThread( stream, outfunc, bufsize, name=None, postFunc=None ): - """Create a thread that reads the stream, calling outfunc for each block, - and calling postFunc when the end of stream is reached. - """ - Popen3.count += 1 - name = name or str( Popen3.count ) - threadName = "StreamReader %s" % name - import threading - reader = threading.Thread( - target=_readStream, - name=threadName, - args=( stream, outfunc, bufsize, postFunc ) - ) - reader.setDaemon( 1 ) - reader.start() - return reader - -def _readStream( instream, outfunc, bufsize, postFunc=None ): - """Read instream, calling outfunc( buf, 0, count ) with each block. - Copy streams by passing destStream.write as the outfunc. - postFunc is called when the end of instream is reached. - """ - bufsize = bufsize < 1 and 4096 or bufsize - buf = jarray.zeros( bufsize, 'b' ) - total = 0 - while 1: - count = instream.read( buf ) - if -1 == count: - instream.close() - if postFunc: postFunc() - break - else: - total += count - outfunc( buf, 0, count ) - return total - class Popen4(Popen3): - """Popen object that joins the stdout and stderr streams into a single - output stream.""" childerr = None def __init__(self, cmd, bufsize=-1): - Popen3.__init__( self, cmd, 1, bufsize ) - self.closed = Vector() # use a vector for synchronization close() - self.fromchild = self._join( - self._fromchild, - self._childerr, - bufsize - ) + _cleanup() + self.cmd = cmd + p2cread, p2cwrite = os.pipe() + c2pread, c2pwrite = os.pipe() + self.pid = os.fork() + if self.pid == 0: + # Child + os.dup2(p2cread, 0) + os.dup2(c2pwrite, 1) + os.dup2(c2pwrite, 2) + self._run_child(cmd) + os.close(p2cread) + self.tochild = os.fdopen(p2cwrite, 'w', bufsize) + os.close(c2pwrite) + self.fromchild = os.fdopen(c2pread, 'r', bufsize) - def _join( self, stdout, stderr, bufsize ): - """create a stream that joins two output streams""" - self._pipeOut = PipedOutputStream() - joinedStream = PipedInputStream( self._pipeOut ) - self._outReader = _makeReaderThread( - stdout, - self._pipeOut.write, - bufsize, - "%s-stdout" % self.process, - self._close - ) - self._errReader = _makeReaderThread( - stderr, - self._pipeOut.write, - bufsize, - "%s-stderr" % self.process, - self._close - ) - return FileUtil.wrap(joinedStream, 0) - def _close( self ): - """Must be closed twice (once for each of the two joined pipes)""" - self.closed.add( None ) - if self.closed.size() > 1: - self._pipeOut.close() +if sys.platform[:3] == "win" or sys.platform == "os2emx": + # Some things don't make sense on non-Unix platforms. + del Popen3, Popen4 -def popen(path, mode='r', bufsize=-1): - p = Popen3( path, 0, bufsize ) - if mode == 'r': - return _ProcessFile(p.fromchild, p.process, path) - elif mode == 'w': - return _ProcessFile(p.tochild, p.process, path) - else: - raise OSError(0, "Invalid mode", mode) + def popen2(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin) are returned.""" + w, r = os.popen2(cmd, mode, bufsize) + return r, w -def popen2(path, mode="t", bufsize=-1): - p = Popen3(path, 0, bufsize) - return p.fromchild, p.tochild + def popen3(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin, child_stderr) are returned.""" + w, r, e = os.popen3(cmd, mode, bufsize) + return r, w, e -def popen3(path, mode="t", bufsize=-1): - p = Popen3(path, 1, bufsize) - return p.fromchild, p.tochild, p.childerr + def popen4(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout_stderr, child_stdin) are returned.""" + w, r = os.popen4(cmd, mode, bufsize) + return r, w +else: + def popen2(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin) are returned.""" + inst = Popen3(cmd, False, bufsize) + return inst.fromchild, inst.tochild -def popen4(path, mode="t", bufsize=-1): - p = Popen4(path, bufsize) - return p.fromchild, p.tochild + def popen3(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout, child_stdin, child_stderr) are returned.""" + inst = Popen3(cmd, True, bufsize) + return inst.fromchild, inst.tochild, inst.childerr -def system( cmd ): - """Imitate the standard library 'system' call. - Execute 'cmd' in a shell, and send output to stdout & stderr. + def popen4(cmd, bufsize=-1, mode='t'): + """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may + be a sequence, in which case arguments will be passed directly to the + program without shell intervention (as with os.spawnv()). If 'cmd' is a + string it will be passed to the shell (as with os.system()). If + 'bufsize' is specified, it sets the buffer size for the I/O pipes. The + file objects (child_stdout_stderr, child_stdin) are returned.""" + inst = Popen4(cmd, bufsize) + return inst.fromchild, inst.tochild - This is in popen2 only because its Jython implementation is similar to - that of the popen functions. - """ - bufsize = 4096 - # this uses some Popen3 internals, and thus belongs in popen3 - # os.system should also be this function - p = Popen3( cmd, 1, bufsize) - p.tochild.close() - - # read stderr in separate thread - errReader = _makeReaderThread( - p._childerr, - System.err.write, - bufsize, - "stderr" - ) + __all__.extend(["Popen3", "Popen4"]) - # read stdin in main thread - _readStream( - p._fromchild, - System.out.write, - bufsize - ) - - status = p.wait() - return status - def _test(): - # _test comes from python22/lib/popen2.py + # When the test runs, there shouldn't be any open pipes + _cleanup() + assert not _active, "Active pipes when test starts " + repr([c.cmd for c in _active]) cmd = "cat" teststr = "ab cd\n" - import os - if os.name in [ "nt", "java" ]: + if os.name == "nt": cmd = "more" # "more" doesn't act the same way across Windows flavors, # sometimes adding an extra newline at the start or the @@ -275,7 +219,7 @@ w.close() got = r.read() if got.strip() != expected: - raise ValueError("wrote %s read %s" % (teststr, got)) + raise ValueError("wrote %r read %r" % (teststr, got)) print "testing popen3..." try: r, w, e = popen3([cmd]) @@ -284,26 +228,17 @@ w.write(teststr) w.close() got = r.read() - err = e.read() if got.strip() != expected: - raise ValueError("wrote %s read %s, error %s" % (teststr, got, err )) - if err: - raise ValueError("unexected %s on stderr" % err ) -# this portion of the test is inapplicable to the Jython implementation -# for inst in _active[:]: -# inst.wait() -# if _active: -# raise ValueError("_active not empty") + raise ValueError("wrote %r read %r" % (teststr, got)) + got = e.read() + if got: + raise ValueError("unexpected %r on stderr" % (got,)) + for inst in _active[:]: + inst.wait() + _cleanup() + if _active: + raise ValueError("_active not empty") print "All OK" - p = Popen3( cmd ) - q = "This is\na test of\nwriting\n" - p.tochild.write( q ) - p.tochild.close() - r = p.fromchild.read() - x = p.poll() - assert x == 0 - assert r.strip() == q.strip() - if __name__ == '__main__': _test() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 05:55:19
|
Revision: 6152 http://jython.svn.sourceforge.net/jython/?rev=6152&view=rev Author: pjenvey Date: 2009-04-03 05:54:58 +0000 (Fri, 03 Apr 2009) Log Message: ----------- test for r6149 Modified Paths: -------------- trunk/jython/Lib/test/test_subprocess.py Modified: trunk/jython/Lib/test/test_subprocess.py =================================================================== --- trunk/jython/Lib/test/test_subprocess.py 2009-04-03 01:41:38 UTC (rev 6151) +++ trunk/jython/Lib/test/test_subprocess.py 2009-04-03 05:54:58 UTC (rev 6152) @@ -697,6 +697,10 @@ [sys.executable, "-c", "import sys; sys.exit(47)"], preexec_fn=lambda: 1) + # invalid command line args should raise TypeError + self.assertRaises(TypeError, subprocess.call, + [sys.executable, + "-c", 1]) def test_main(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-04-03 02:22:14
|
Revision: 6151 http://jython.svn.sourceforge.net/jython/?rev=6151&view=rev Author: fwierzbicki Date: 2009-04-03 01:41:38 +0000 (Fri, 03 Apr 2009) Log Message: ----------- Archive the old 2.1 website in prep for a new one. Added Paths: ----------- trunk/website/archive/ trunk/website/archive/21/ trunk/website/archive/21/.htaccess trunk/website/archive/21/Jython21.html trunk/website/archive/21/MacOS_Install.html trunk/website/archive/21/MacOS_Install2.html trunk/website/archive/21/MacOS_Install3.html trunk/website/archive/21/MacOS_Install4.html trunk/website/archive/21/MacOS_Install5.html trunk/website/archive/21/NEWS.html trunk/website/archive/21/accu04-scripting/ trunk/website/archive/21/accu04-scripting/accu04-scripting.tgz trunk/website/archive/21/accu04-scripting/doctest.html trunk/website/archive/21/accu04-scripting/doctest_out.html trunk/website/archive/21/accu04-scripting/glue.html trunk/website/archive/21/accu04-scripting/ijyside.html trunk/website/archive/21/accu04-scripting/import.html trunk/website/archive/21/accu04-scripting/index.html trunk/website/archive/21/accu04-scripting/intro0.html trunk/website/archive/21/accu04-scripting/intro1.html trunk/website/archive/21/accu04-scripting/intro2.html trunk/website/archive/21/accu04-scripting/jython-new-small.gif trunk/website/archive/21/accu04-scripting/pinterp1.html trunk/website/archive/21/accu04-scripting/search_snpt.html trunk/website/archive/21/accu04-scripting/talk.css trunk/website/archive/21/accu04-scripting/tasks_snpt.html trunk/website/archive/21/applets/ trunk/website/archive/21/applets/JythonLoader.class trunk/website/archive/21/applets/JythonLoader.java trunk/website/archive/21/applets/appletdemo.cab trunk/website/archive/21/applets/appletdemo.jar trunk/website/archive/21/applets/button.html trunk/website/archive/21/applets/checkbox.html trunk/website/archive/21/applets/choice.html trunk/website/archive/21/applets/converter.html trunk/website/archive/21/applets/coordinates.html trunk/website/archive/21/applets/index.html trunk/website/archive/21/applets/issues.html trunk/website/archive/21/applets/label.html trunk/website/archive/21/applets/list.html trunk/website/archive/21/applets/problems.html trunk/website/archive/21/css/ trunk/website/archive/21/css/.profile.css.swp trunk/website/archive/21/css/PythonPoweredSmall.gif trunk/website/archive/21/css/basic.css trunk/website/archive/21/css/html4css1.css trunk/website/archive/21/css/jython.png trunk/website/archive/21/css/moin-www.png trunk/website/archive/21/css/pngfix.js trunk/website/archive/21/css/print.css trunk/website/archive/21/css/profile.css trunk/website/archive/21/css/screen.css trunk/website/archive/21/docs/ trunk/website/archive/21/docs/compile.html trunk/website/archive/21/docs/differences.html trunk/website/archive/21/docs/embedding.html trunk/website/archive/21/docs/index.html trunk/website/archive/21/docs/interpreter.html trunk/website/archive/21/docs/jarray.html trunk/website/archive/21/docs/jreload.html trunk/website/archive/21/docs/jythonc.html trunk/website/archive/21/docs/properties.html trunk/website/archive/21/docs/registry.html trunk/website/archive/21/docs/subclassing.html trunk/website/archive/21/docs/usejava.html trunk/website/archive/21/docs/whatis.html trunk/website/archive/21/docs/zxjdbc.html trunk/website/archive/21/download.html trunk/website/archive/21/graphics/ trunk/website/archive/21/graphics/powered03.gif trunk/website/archive/21/graphics/sample01.html trunk/website/archive/21/graphics/sample03.html trunk/website/archive/21/graphics/sample04.html trunk/website/archive/21/graphics/small01.jpg trunk/website/archive/21/graphics/small02.gif trunk/website/archive/21/graphics/small03.gif trunk/website/archive/21/graphics/small04.gif trunk/website/archive/21/graphics.html trunk/website/archive/21/images/ trunk/website/archive/21/images/Jython4JavaProgrammers.jpg trunk/website/archive/21/images/JythonEss.jpg trunk/website/archive/21/images/PythonPoweredSmall.gif trunk/website/archive/21/images/ineclipse2.png trunk/website/archive/21/images/jython-new-small.gif trunk/website/archive/21/index.html trunk/website/archive/21/install.html trunk/website/archive/21/jpython-talk-1.ppt trunk/website/archive/21/left.nav trunk/website/archive/21/license.html trunk/website/archive/21/mac/ trunk/website/archive/21/mac/Jython_MacOS_Install.html trunk/website/archive/21/mac/j_get_work1.gif trunk/website/archive/21/mac/jbindery_1.gif trunk/website/archive/21/mac/jython_console.gif trunk/website/archive/21/mac/jython_dest.gif trunk/website/archive/21/mac/jython_get.gif trunk/website/archive/21/mac/jython_get_2.gif trunk/website/archive/21/mac/jython_get_3.gif trunk/website/archive/21/mac/jython_install_1.gif trunk/website/archive/21/mac/jython_install_2.gif trunk/website/archive/21/mac/jython_install_3.gif trunk/website/archive/21/mac/jython_klick1.gif trunk/website/archive/21/mac/jython_klick_2.gif trunk/website/archive/21/mac/jython_klick_3.gif trunk/website/archive/21/mac/jython_run_1.gif trunk/website/archive/21/mac/mrj_jbindery.gif trunk/website/archive/21/mac/mrj_sdk_2_2.gif trunk/website/archive/21/platform.html trunk/website/archive/21/users.html Added: trunk/website/archive/21/.htaccess =================================================================== --- trunk/website/archive/21/.htaccess (rev 0) +++ trunk/website/archive/21/.htaccess 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,9 @@ +<IfModule mod_rewrite.c> + RewriteEngine On + RewriteRule ^bugs/?$ http://bugs.jython.org/ + RewriteRule ^bugs/(.+)$ http://bugs.jython.org/issue$1 + RewriteRule ^patches/?$ http://bugs.jython.org/ + RewriteRule ^patches/(.+)$ http://bugs.jython.org/issue$1 + RewriteRule ^buildbot$ http://jython.achievewith.us/buildbot/ + RewriteRule ^buildbot(.*)$ http://jython.achievewith.us/buildbot$1 +</IfModule> Added: trunk/website/archive/21/Jython21.html =================================================================== --- trunk/website/archive/21/Jython21.html (rev 0) +++ trunk/website/archive/21/Jython21.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,448 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Wed Mar 16 10:38:58 2005 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: Jython Home Page + +--> + +<head> +<title>Jython Home Page</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<p>Welcome to the Jython homepage. Jython is an implementation of +the high-level, dynamic, object-oriented language +<a href="http://www.python.org/">Python</a> written in +100% Pure Java, and seamlessly integrated with +the <a href="http://www.javasoft.com">Java</a> platform. It thus +allows you to run Python on any Java platform. + +<ul> +<li>What is <A HREF="docs/whatis.html">Jython</A>? +<li>Jython <a href="http://wiki.python.org/jython/">WIKI</a>. +<li><A HREF="download.html">Download</a> the latest version. +<li><A HREF="docs/index.html">Documentation</A> +<li>The Jython <A HREF="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</A>. +<li>Brian Zimmer's <a href="http://www.ziclix.com/bzimmer/">Jython development blog</a></li> +<li><a href="https://coyote.dev.java.net/">Jython support in NetBeans</a></li> + +</ul> + + <dd><i><blockquote> + Jython, lest you do not know of it, is the most compelling weapon the Java platform has for its survival into the 21st century:-) + <br>— <cite><a href="http://seanmcgrath.blogspot.com/2003_07_27_seanmcgrath_archive.html#105971971904416520">Sean McGrath, CTO, Propylon</a></cite> + </blockquote></i> + +<h3><font size=+1 color="#666699">Jython News</font></h3> + +<dl> +<p><dt><b>16th March 2005</b></dt></p> +<li>Jython support in <a href="http://www.netbeans.org">NetBeans</a> has been announced as part of a more general dynamic languages support initiative for NetBeans called <a href="https://coyote.dev.java.net/">Coyote</a>. See blog entries by <a href="http://www.tbray.org/ongoing/When/200x/2005/03/15/Coyote">Tim Bray</a> and <a href="http://blogs.sun.com/roller/page/webmink/20050315#doing_java_without_java">Simon Phipps</a> of Sun Microsystems. +</li> +</dl> + + + +<dl> +<p><dt><b>14th February 2005</b></dt></p> +<li>The Jython <a href="http://wiki.python.org/jython/">WIKI</a> +is up and running. Thanks to <a +href="http://www.dehora.net/journal/">Bill de h\xD3ra</a> who did much of +the running to get this set up.</li> +</dl> + +<dl> +<p><dt><b>24th January 2005</b></dt></p> +<li>Brian Zimmer has started a Jython development blog : <a href="http://www.ziclix.com/bzimmer/">http://www.ziclix.com/bzimmer/</a></li> + +</dl> + +<dl> +<p><dt><b>14 January 2005</b></dt></p> + +<p>The PSF recently published its <a +href="http://www.python.org/psf/grants/">list of projects</a> to +recieve grant funding. Brian Zimmer will manage the project <a +href="http://www.python.org/psf/grants/Jython_PSF_Grant_Proposal.pdf">Moving +Jython Forward</a>. + +<p>A new article on <a +href="http://www.devx.com/Java/Article/26602">writing Eclipse JUnit +tests in Jython</a></p> + +<p>Random Jython Spotlight: <a +<a href="http://staf.sourceforge.net/index.php">STAF (Software Testing Automation Framework)</a> uses Jython for its execution engine <a href="http://staf.sourceforge.net/index.php#STAXOverview">STAX</a> (Added to <a href="users.html">Jython users page</a>. +</dl> + +<dl> +<p><dt><b>21 December 2004</b></dt></p> + +<p><a href="http://sulu.sourceforge.net/">Sulu</a> added to <a href="users.html">Jython Users Page</a>. +<p><a href="http://www.jedit.org/">jEdit</a> added to <a href="users.html">Jython Users Page</a>. + + +<p><dt><b>20 December 2004</b></dt></p> + +<p><a +href="http://www.tbray.org/ongoing/When/200x/2004/12/19/NB4-plus">Tim +Bray</a> announces an upcoming <a +href="http://www.java.net">java.net</a> project to add +dynamic-language infrastructure, including Jython, to the <a +href="http://www.netbeans.org/">NetBeans</a> IDE. + +<p><dt><b>19 December 2004</b></dt></p> + +<p>Samuele Pedroni, Guido van Rossum and Sean McGrath represent the +Python community at a dynamic languages <a +href="http://www.tbray.org/ongoing/When/200x/2004/12/08/DynamicJava">summit</a>. +Hosted by <a href="http://www.tbray.org/ongoing/">Tim Bray</a> of Sun.</p> + +<p><a href="users.html">Who uses Jython?</a> page updated.</p> + +<p>Random Jython Spotlight: <a +href="http://www.smallshire.org.uk/jython3d.htm">Jython3D</a> +combining Jython and Java3D. + +<p><dt><b>25 October 2004: website revamp announced</b></dt></p> + +<p>Over the next short while, the Jython website will be +revamped. Suggestions for the revamp welcome. Send suggestions to the +Jython developer mailing list.</p> + +<p><dt><b>25 October 2004: Progress on new-style classes +implementation</b></dt></p> + +<p> +Samuele Pedroni is making strong progress in the end-to-end +modifications required to the Jython code-base in order to support +new-style classes. The implementation of new style classes in Jython +is a key moment on the road to compatibility with CPython 2.3 and +beyond. + +Samuele plans to make an initial check-in of the branch on or around +<b>15 November 2004</b>. Stay tuned for further updates. + +For more details about the state of play, see the jython-dev archive <a href="http://sourceforge.net/mailarchive/forum.php?thread_id=5754593&forum_id=5587">here</a> and <a href="http://sourceforge.net/mailarchive/message.php?msg_id=9838528">here</a> + +<p><dt><b>25 October 2004: Jython tutorial</b></dt></p> + +<p> +Barry Feigenbaum has written a substantial two part Jython tutorial on +using Jython. The tutorial consists of two PDF files: <a +href="j-jython1-ltr.pdf">Part 1</a> (82 pages) and <a +href="j-jython2-ltr.pdf">Part 2</a> (100 pages). First published by IBM developerWorks at <a +href="http://www.ibm.com/developerWorks/">http://www.ibm.com/developerWorks/</a>. +</p> + + <p><dt><b>April 2004: Newstyle branch work.</b> + <dd> Work is undergoing since the beginning of the year to implement new-style classes + features (the biggest quantum-leap post 2.1 missing feature for a new release) on the newstyle-branch in the CVS (see e.g. <a href="http://cvs.sourceforge.net/viewcvs.py/jython/jython/org/python/core/Attic/PyType.java?only_with_tag=newstyle-branch">this check-in</a>). <b> There will be a new alpha release when this branch will be merged to the trunk. We expect then a new release for the summer, with 2.2 and some 2.3 features. Leading up to the release this site will be revamped.</b> + + <p><dt><b>31 July 2003 : Jython 2.2 alpha 0 available</b> + + <dd>Experimental, unstable release of Jython now available. This is an + alpha release, in that it is not feature complete for a Jython 2.2 + release, and there are significant known issues. + <p> + This is a snapshot that contains a mixture of Python 2.1 and 2.2 + features. Use this release at your own risk. + <p> + There has been no validation of which parts of the Python + library are functional with this relase. Expect pickle and + related modules to be broken, probably others as well. + <p> + <a href="jython22a0.zip">jython22a0.zip</a>| + <a href="README.txt">readme.txt<br></a> + +</dl> +<hr> +<dl> + <p><b>Older news items from the Jython project</b></p> + + <p><dt><b>Work in progress</b> + <dd>Something from history: + <ul><li> Python 1.5.2 was realeased on 14 Apr 1999. + <li> Python 2.0 was released on 20 Oct 2000.</ul> + + Indeed 2.1 (corresponding feature-wise to CPython 2.1) is becoming our 1.5.2, + it is not perfect but quite stable and can be used for real work, and is also + documented in print: + <ul> + <li><i><a href="http://www.oreilly.com/catalog/jythoness/"> + Jython Essentials</a></i> by Samuele Pedroni, Noel Rappin, + <a href="http://www.oreilly.com/">O'Reilly</a> + <img border="0" align="middle"src="./images/JythonEss.jpg" + alt="Jython Essentials cover" > + <li><i>Jython for Java Programmers</i> by Robert W. Bill, + <a href="http://www.newriders.com/">New Riders</a>. + <img border="0" align="middle"src="./images/Jython4JavaProgrammers.jpg" + alt="Jython for Java Programmers cover" > + </ul> + + Last year we have been working toward a new release with CPython 2.2/2.3 + features, and we are working on it. <br> + + Development peekholes: + <ul> + <li><a href="http://sf.net/projects/jython/">Jython on SourceForge</a> + <li><a href="http://sf.net/cvs/?group_id=12867">Jython CVS</a> + <li><a href="http://sourceforge.net/mailarchive/forum.php?forum_id=5588">Jython checkins maillist</a> + </ul> (jan 2003). + + <p><dt><b>Jython 2.1 released!</b> + <dd>Download the latest stable relase of Jython + <a href="download.html">here</a> and + <a href="NEWS.html">read a summary</a> of recent changes.<br> + (31-dec-2001). + + <p><dt><b>New website layout.</b> + <dd>New colors and an jython icon created by Ivan Kougaenko. (15-jan-2001). + + <p><dt><b>Step by step installation instruction for MacOS.</b> + <dd>L. Humbert has contributed a <a href="MacOS_Install.html">guide</a> + for installation and setup of Jython on MacOS. (27-dec-2000). + + <p><dt><b>Jython project announced</b> + <dd>The Jython project have been created on sourceforge. Read the + <a href="http://www.python.org/pipermail/jpython-interest/2000-October/003998.html"> + announcement</a> (19-oct-2000). +</dl> + + +<h3><font size=+1 color="#666699">Jython In the press</font></h3> + +<dl> + <p><dt><b>10-jun-2003</b> + <dd><a href="http://today.java.net/pub/a/today/2003/06/10/jython.html">Scripting with Jython Instead of XML</a>, + Jonathan Simon on <a href="http://java.net/">java.net</a> + + <p><dt><b>6-may-2003</b> + <dd>Uche Ogbuij in IBM developerWorks + <a href="http://www-106.ibm.com/developerworks/java/library/j-jython.html">Charming Jython</a> + + <p><dt><b>11-apr-2002</b> + <dd>Noel Rappin has written another + <a href="http://www.onjava.com/pub/a/onjava/2002/03/27/jython.html"> + article</a> with jython tips for python programmers. + + <p><dt><b>2-apr-2002</b> + <dd>Our second Jython book called + <i><a href="http://www.oreilly.com/catalog/jythoness/"> + Jython Essentials</a></i> was written by By Noel Rappin and + Samuele Pedroni and published by <a href="http://www.oreilly.com/"> + O'Reilly</a>. + + <p><dt><b>28-mar-2002</b> + <dd>Noel Rappin has written an + <a href="http://www.onjava.com/pub/a/onjava/2002/03/27/jython.html"> + article</a> on how to script java with Jython. + + <p><dt><b>15-jan-2002</b> + <dd>The very first Jython book called + <i><a href="http://www.newriders.com/books/title.cfm?isbn=0735711119"> + Jython for Java Programmers</a></i> was written by Robert W. Bill + and published by <a href="http://www.newriders.com/">New Riders</a>. + + <p><dt><b>8-apr-2001</b> + <dd>Ross Lonstein has written an + <a href="http://www.agoron.com/~lonstein/articles/jython-bsf.html">article</a> + on how Jython can be integrated with + <a href="http://oss.software.ibm.com/developerworks/projects/bsf">BSF</a>. + + <p><dt><b>12-mar-2001</b> + <dd>Weiqi Gao <a href="http://www.ociweb.com/jnb/archive/jnbMar2001.html">shows</a> + scripting examples using Jython and Rhino (javascript). + + <p><dt><b>18-dec-2000</b> + <dd>Jon Udell + <a href="http://www.byte.com/documents/s=505/BYT20001214S0006/">talks</a> + about using the JVM to implement other languages, among them JPython. + + <p><dt><b>8-dec-2000</b> + <dd>Bruce Eckel has release a new revision of his + <a href="http://www.mindview.net/Books/TIPatterns/"> + Thinking in Patterns with Java</a> book and chapter 9 has been updated to + cover Jython. + + <p><dt><b>5-dec-2000</b> + <dd>David Mertz has written an + <a href="http://gnosis.cx/publish/programming/charming_python_10.txt">interview</a> + with some of the jython developers + + <p><dt><b>8-nov-2000</b> + <dd>JPython is mentioned in an + <a href="http://www.javasoft.com/features/2000/11/dotnetvsms.html?frontpage-banner"> + article</a> that compares the Java platform with MicroSoft's .NET + + +</dl> + +<font size=-1> last updated 20-jun-2003 </font> + + + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/MacOS_Install.html =================================================================== --- trunk/website/archive/21/MacOS_Install.html (rev 0) +++ trunk/website/archive/21/MacOS_Install.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,193 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:24 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: How to install Jython on Macintosh + +--> + +<head> +<title>How to install Jython on Macintosh</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<h3>How to install Jython on Macintosh</h3> + +<ul> +<li>Install the java development kit: <a + href="ftp://ftp.apple.com/developer/Development_Kits/MRJ_SDK_2.2_Install.sit.bin"> + ftp://ftp.apple.com/developer/Development_Kits/MRJ_SDK_2.2_Install.sit.bin</a>. + <br>It is from <a href="http://developer.apple.com/java/download.html"> + http://developer.apple.com/java/download.html</a>. + <br>Don't choose MRJ 2.2.3, because it has does not have _batteries included_. +<li>The Jython installer: <a href="http://www.jython.org/download.html">http://www.jython.org/download.html</a> +<li><a href="MacOS_Install2.html">Start the the jython installer</a>. +<li><a href="MacOS_Install3.html">Running the jython installer</a>. +<li><a href="MacOS_Install4.html">Create binding for jython.jar</a>. +<li><a href="MacOS_Install5.html">Run the jython interpreter</a>. +<ul> + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/MacOS_Install2.html =================================================================== --- trunk/website/archive/21/MacOS_Install2.html (rev 0) +++ trunk/website/archive/21/MacOS_Install2.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,203 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:25 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: Start the the jython installer + +--> + +<head> +<title>Start the the jython installer</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<h3>Start the the jython installer</h3> + +<a href="MacOS_Install.html">Previous</a> <a href="MacOS_Install3.html">Next</a> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Install +</td></tr></table><p> + +<img SRC="mac/mrj_SDK_2_2.gif" height=509 width=816> + +<img SRC="mac/mrj_JBindery.gif" BORDER=0 height=477 width=831> + + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Drag and drop the jython installer class on the JBindery Icon: +</td></tr></table><p> + +<img SRC="mac/JBindery_1.gif" BORDER=0 height=506 width=912> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Choose Run +</td></tr></table><p> + +<a href="MacOS_Install.html">Previous</a> <a href="MacOS_Install3.html">Next</a> + + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/MacOS_Install3.html =================================================================== --- trunk/website/archive/21/MacOS_Install3.html (rev 0) +++ trunk/website/archive/21/MacOS_Install3.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,207 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:25 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: Running the jython installer + +--> + +<head> +<title>Running the jython installer</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<h3>Running the jython installer</h3> + +<a href="MacOS_Install2.html">Previous</a> <a href="MacOS_Install4.html">Next</a> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Now the install process should start: +</td></tr></table><p> + + +<img SRC="mac/Jython_Install_1.gif" height=737 width=936> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + At the first step you have to choose, which pakets will be installed +</td></tr></table><p> + +<img SRC="mac/Jython_Install_2.gif" height=465 width=750> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + The System is going to be inspected +</td></tr></table><p> + +<img SRC="mac/Jython_Install_3.gif" height=463 width=747> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + The install process is running +</td></tr></table><p> + +<a href="MacOS_Install2.html">Previous</a> <a href="MacOS_Install4.html">Next</a> + + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/MacOS_Install4.html =================================================================== --- trunk/website/archive/21/MacOS_Install4.html (rev 0) +++ trunk/website/archive/21/MacOS_Install4.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,219 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:25 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: Create binding for jython.jar + +--> + +<head> +<title>Create binding for jython.jar</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<h3>Create binding for jython.jar</h3> + +<a href="MacOS_Install3.html">Previous</a> <a href="MacOS_Install5.html">Next</a> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + After installing, you'll find some new created folders +</td></tr></table><p> + +<img SRC="mac/Jython_dest.gif" height=388 width=639> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Next, the jython.jar - file has to be used to be started. + <p>Here you have to put some data into JBindery: + <br>at first the class name has to be choosen: + <br><strong>org.python.util.jython</strong> +</td></tr></table><p> + +<img SRC="mac/Jython_Klick1.gif" height=382 width=625> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Then the classpath has to be adjusted, so it includes the jython.jar + (I added the Lib-Folder to), you may put any elements you need on this + List. +</td></tr></table><p> + +<img SRC="mac/Jython_klick_2.gif" height=360 width=497> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + Properties have to be set: this is the location, where your Jython-Home + is located. +</td></tr></table><p> + + +<img SRC="mac/Jython_Klick_3.gif" height=357 width=499> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + After all this little steps, <strong>Save Settings</strong> + and then <strong>Run</strong> +</td></tr></table><p> + +<a href="MacOS_Install3.html">Previous</a> <a href="MacOS_Install5.html">Next</a> + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/MacOS_Install5.html =================================================================== --- trunk/website/archive/21/MacOS_Install5.html (rev 0) +++ trunk/website/archive/21/MacOS_Install5.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,194 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:25 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: Run the jython interpreter + +--> + +<head> +<title>Run the jython interpreter</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Exits +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/">Python Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/psf">PSF</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.javasoft.com">Java Language</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Contact +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://lists.sourceforge.net/lists/listinfo/jython-users">Questions on Jython?<br>jython-users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.python.org/"> +<center> + <img border="0" src="./images/PythonPoweredSmall.gif"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/"> +<center> + <img src="http://sourceforge.net/sflogo.php?group_id=12867" width="88" height="31" border="0" alt="SourceForge Logo"></center> +</a> +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> + +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="mailto:jyt...@li...">webmaster</a> +</td></tr> +</table><!-- end of sidebar table --> + +</td> +<td width="15"> </td><!--spacer--> +<!-- end of sidebar cell --> +<!-- start of body cell --> +<td valign="top" width="90%" class="body"><br> +<h3>Run the jython interpreter</h3> + +<a href="MacOS_Install4.html">Previous</a> + +<p> + +<img SRC="mac/Jython_RUN_1.gif" height=254 width=928> + +<p><table bgcolor="#dddddd" width=100%><tr><td> + The jar-Files are (the first time you start it up) processed, and + the Jython-Interpreter is started: +</td></tr></table><p> + +<img SRC="mac/Jython_Console.gif" height=169 width=793> + +<a href="MacOS_Install4.html">Previous</a> + +</td><!-- end of body cell --> +</tr><!-- end of sidebar/body row --> +</table><!-- end of page table --> +</body></html> Added: trunk/website/archive/21/NEWS.html =================================================================== --- trunk/website/archive/21/NEWS.html (rev 0) +++ trunk/website/archive/21/NEWS.html 2009-04-03 01:41:38 UTC (rev 6151) @@ -0,0 +1,607 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<!-- THIS PAGE IS AUTOMATICALLY GENERATED. DO NOT EDIT. --> +<!-- Sat Aug 02 15:23:25 2003 --> +<!-- USING HT2HTML 2.0 --> +<!-- SEE http://ht2html.sf.net --> +<!-- User-specified headers: +Title: NEWS.ht + +--> + +<head> +<title>NEWS.ht</title> +<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> +<meta name="generator" content="HT2HTML/2.0"> +<style type="text/css"> +body { margin: 0px; } +</style> +</head> +<body bgcolor="#ffffff" text="#000000" + marginwidth="0" marginheight="0" + link="#0000bb" vlink="#00000" + alink="#ff0000"> +<!-- start of page table --> +<table width="100%" border="0" cellspacing="0" cellpadding="0"> +<!-- start of banner row --> +<tr> +<!-- start of corner cells --> +<td width="150" valign="middle" bgcolor="#cccccc" class="corner"> + +<center> + <a href="./"> + <img border="0" src="./images/jython-new-small.gif"></a></center> </td> +<td width="15" bgcolor="#cccccc"> </td><!--spacer--> +<!-- end of corner cells --> +<!-- start of banner --> +<td width="90%" bgcolor="#cccccc" class="banner"> +<!-- start of site links table --> +<table width="100%" border="0" +cellspacing="0" cellpadding="2" + bgcolor="#ffffff"> +<tr> + <td bgcolor="#cccccc"> +<a href="./">Home</a> + </td> + <td bgcolor="#cccccc"> +<a href="http://www.python.org/">www.python.org</a> + </td> +</tr><tr> + <td bgcolor="#cccccc"> +<a href="./download.html">Download</a> + </td> + <td bgcolor="#cccccc"> +<a href="./docs/index.html">Documentation</a> + </td> +</tr> +</table><!-- end of site links table --> + +</td><!-- end of banner --> +</tr><!-- end of banner row --> +<tr><!-- start of sidebar/body row --> +<!-- start of sidebar cells --> +<td width="150" valign="top" bgcolor="#cccccc" class="sidebar"> +<!-- start of sidebar table --> +<table width="100%" border="0" cellspacing="0" cellpadding="3" + bgcolor="#ffffff"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Home +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="./index.html">Overview</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="license.html">License</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="download.html">Jython 2.1</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="install.html">Installing</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="platform.html">JVM Compatibility</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Resources +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="applets/index.html">Applet Demos</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/mail/?group_id=12867">Mailling Lists (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://sourceforge.net/bugs/?group_id=12867">Bugs (exit)</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="users.html">Jython Users</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<tr><td bgcolor="#666699"><b><font color="#ffffff"> +Doc Quick Links +</font></b></td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/whatis.html">What is Jython</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="docs/index.html">All Documentation</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jython.org/cgi-bin/faqw.py?req=index">FAQ</a> +</td></tr> +<tr><td bgcolor="#cccccc"> +<a href="http://www.jpython.org/jpython-talk-1.ppt">JimH's Slides</a> +</td></tr> +<tr... [truncated message content] |
From: <pj...@us...> - 2009-04-03 01:01:39
|
Revision: 6150 http://jython.svn.sourceforge.net/jython/?rev=6150&view=rev Author: pjenvey Date: 2009-04-03 01:01:25 +0000 (Fri, 03 Apr 2009) Log Message: ----------- give stats a repr Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-04-03 00:52:31 UTC (rev 6149) +++ trunk/jython/Lib/os.py 2009-04-03 01:01:25 UTC (rev 6150) @@ -198,7 +198,7 @@ def __init__(self, results): if len(results) != 10: - raise TypeError("stat_result() takes an a 10-sequence") + raise TypeError("stat_result() takes an a 10-sequence") for (name, index) in stat_result._stat_members: self.__dict__[name] = results[index] @@ -234,6 +234,10 @@ return 1 return cmp(self.__dict__, other.__dict__) + def __repr__(self): + return repr(tuple(self.__dict__[member[0]] for member + in stat_result._stat_members)) + error = OSError def _exit(n=0): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-03 00:52:45
|
Revision: 6149 http://jython.svn.sourceforge.net/jython/?rev=6149&view=rev Author: pjenvey Date: 2009-04-03 00:52:31 +0000 (Fri, 03 Apr 2009) Log Message: ----------- ensure sane args to subprocess, fix OSError message Modified Paths: -------------- trunk/jython/Lib/subprocess.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-04-02 02:32:59 UTC (rev 6148) +++ trunk/jython/Lib/subprocess.py 2009-04-03 00:52:31 UTC (rev 6149) @@ -1143,7 +1143,14 @@ if isinstance(args, types.StringTypes): args = [args] else: - args = escape_args(list(args)) + args = list(args) + for arg in args: + # XXX: CPython posix (execv) will str() any unicode + # args first, maybe we should do the same on + # posix. Windows passes unicode through however + if not isinstance(arg, (str, unicode)): + raise TypeError('args must contain only strings') + args = escape_args(args) if shell: args = shell_command + args @@ -1171,7 +1178,7 @@ elif not os.path.exists(cwd): raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), cwd) elif not os.path.isdir(cwd): - raise OSError(errno.ENOTDIR, os.strerror(errno.ENOENT), cwd) + raise OSError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), cwd) builder.directory(java.io.File(cwd)) # Let Java manage redirection of stderr to stdout (it's more This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-04-02 02:33:01
|
Revision: 6148 http://jython.svn.sourceforge.net/jython/?rev=6148&view=rev Author: zyasoft Date: 2009-04-02 02:32:59 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Fixed #1283 by ensuring that all opens in pkgutil use finally to close. Modified Paths: -------------- trunk/jython/Lib/pkgutil.py Modified: trunk/jython/Lib/pkgutil.py =================================================================== --- trunk/jython/Lib/pkgutil.py 2009-04-01 13:54:58 UTC (rev 6147) +++ trunk/jython/Lib/pkgutil.py 2009-04-02 02:32:59 UTC (rev 6148) @@ -241,8 +241,12 @@ return mod def get_data(self, pathname): - return open(pathname, "rb").read() - + f = open(pathname, "rb") + try: + return f.read() + finally: + f.close() + def _reopen(self): if self.file and self.file.closed: mod_type = self.etc[2] @@ -293,8 +297,10 @@ elif mod_type==imp.PY_COMPILED: if os.path.exists(self.filename[:-1]): f = open(self.filename[:-1], 'rU') - self.source = f.read() - f.close() + try: + self.source = f.read() + finally: + f.close() elif mod_type==imp.PKG_DIRECTORY: self.source = self._get_delegate().get_source() return self.source @@ -538,11 +544,13 @@ sys.stderr.write("Can't open %s: %s\n" % (pkgfile, msg)) else: - for line in f: - line = line.rstrip('\n') - if not line or line.startswith('#'): - continue - path.append(line) # Don't check for existence! - f.close() + try: + for line in f: + line = line.rstrip('\n') + if not line or line.startswith('#'): + continue + path.append(line) # Don't check for existence! + finally: + f.close() return path This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-04-01 14:36:13
|
Revision: 6147 http://jython.svn.sourceforge.net/jython/?rev=6147&view=rev Author: otmarhumbel Date: 2009-04-01 13:54:58 +0000 (Wed, 01 Apr 2009) Log Message: ----------- early initialize of the frame installer's java properties Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/FrameInstaller.java trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java Modified: trunk/installer/src/java/org/python/util/install/FrameInstaller.java =================================================================== --- trunk/installer/src/java/org/python/util/install/FrameInstaller.java 2009-04-01 04:28:21 UTC (rev 6146) +++ trunk/installer/src/java/org/python/util/install/FrameInstaller.java 2009-04-01 13:54:58 UTC (rev 6147) @@ -42,6 +42,7 @@ if (commandLine.hasJavaHomeOption()) { setJavaHomeHandler(commandLine.getJavaHomeHandler()); } + initDefaultJava(); Wizard wizard = new Wizard(jarInfo, autotest); wizard.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { @@ -156,6 +157,12 @@ return TRUE.equals(getProperty(TextKeys.ACCEPT_PROPERTY, FALSE)); } + protected static void initDefaultJava() { + JavaVersionInfo javaVersionInfo = new JavaVersionInfo(); + Installation.fillJavaVersionInfo(javaVersionInfo, System.getProperties()); + FrameInstaller.setJavaVersionInfo(javaVersionInfo); + } + private class SimpleWizardListener implements WizardListener { public void wizardStarted(WizardEvent event) { } Modified: trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java 2009-04-01 04:28:21 UTC (rev 6146) +++ trunk/installer/test/java/org/python/util/install/FrameInstallerTest.java 2009-04-01 13:54:58 UTC (rev 6147) @@ -6,6 +6,21 @@ public class FrameInstallerTest extends TestCase { + public void testInitDefaultJava() { + FrameInstaller.initDefaultJava(); + JavaVersionInfo vInfo = FrameInstaller.getJavaVersionInfo(); + assertNotNull(vInfo); + String version = vInfo.getVersion(); + assertNotNull(version); + assertTrue(version.length() > 0); + String specificationVersion = vInfo.getSpecificationVersion(); + assertNotNull(specificationVersion); + assertTrue(specificationVersion.length() > 0); + String vendor = vInfo.getVendor(); + assertNotNull(vendor); + assertTrue(vendor.length() > 0); + } + public void testJavaVersionInfo() { String version = "1;2;3"; String vendor = "jython [macrosystems]"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-04-01 04:28:24
|
Revision: 6146 http://jython.svn.sourceforge.net/jython/?rev=6146&view=rev Author: thobes Date: 2009-04-01 04:28:21 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Moved the code for exercising the SSA graph to the Kenai project. Modified Paths: -------------- trunk/sandbox/tobias/.classpath Removed Paths: ------------- trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java Modified: trunk/sandbox/tobias/.classpath =================================================================== --- trunk/sandbox/tobias/.classpath 2009-04-01 01:45:35 UTC (rev 6145) +++ trunk/sandbox/tobias/.classpath 2009-04-01 04:28:21 UTC (rev 6146) @@ -11,6 +11,7 @@ <classpathentry kind="src" path="jython/build/gensrc"/> <classpathentry kind="src" path="jython/tests/java"/> <classpathentry kind="src" path="compiler/test"/> + <classpathentry kind="src" path="ssa/test"/> <classpathentry kind="lib" path="jython/Demo/jreload/example.jar"/> <classpathentry kind="lib" path="jython/extlibs/antlr-2.7.7.jar"/> <classpathentry kind="lib" path="jython/extlibs/asm-3.1.jar"/> Deleted: trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java =================================================================== --- trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java 2009-04-01 01:45:35 UTC (rev 6145) +++ trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java 2009-04-01 04:28:21 UTC (rev 6146) @@ -1,34 +0,0 @@ -package org.python.compiler.sea.output; - -import org.python.compiler.sea.PythonOperation; -import org.thobe.compiler.sea.GraphBuilder; -import org.thobe.compiler.sea.GraphVisitor; -import org.thobe.compiler.sea.NamespacePopulator; -import org.thobe.compiler.sea.Node; -import org.thobe.compiler.sea.ValueNode; -import org.thobe.compiler.sea.VariableFactory; - -public final class BuildGraph extends GraphBuilder { - protected BuildGraph(NamespacePopulator populator) { - super(populator); - } - - public static void main(String[] args) { - BuildGraph builder = new BuildGraph(new NamespacePopulator() { - public void populate(VariableFactory factory) { - factory.createLocalVariable("x"); - factory.createLocalVariable("y"); - } - }); - ValueNode load_x = builder.loadVariable(builder.variable("x")); - ValueNode load_y = builder.loadVariable(builder.variable("y")); - ValueNode add = builder.schedule(builder.invoke( - PythonOperation.BINARY_ADD, load_x.result(), load_y.result())); - builder.schedule(builder.returnValue(add.result())); - builder.build().serialize(new GraphVisitor() { - public void node(Node node) { - System.out.println(node); - } - }); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-04-01 02:22:50
|
Revision: 6144 http://jython.svn.sourceforge.net/jython/?rev=6144&view=rev Author: thobes Date: 2009-04-01 01:37:23 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Moved the SSA compiler to Kenai. Modified Paths: -------------- trunk/sandbox/tobias/.classpath trunk/sandbox/tobias/build.xml Removed Paths: ------------- trunk/sandbox/tobias/compiler/src/org/thobe/ Property Changed: ---------------- trunk/sandbox/tobias/ Property changes on: trunk/sandbox/tobias ___________________________________________________________________ Modified: svn:externals - jython https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython frame https://kenai.com/svn/jvm-frame-introspect~svn/frame + jython https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython frame https://kenai.com/svn/jvm-frame-introspect~svn/frame ssa https://kenai.com/svn/ssa-compiler~svn-temprep/trunk Modified: trunk/sandbox/tobias/.classpath =================================================================== --- trunk/sandbox/tobias/.classpath 2009-04-01 00:07:49 UTC (rev 6143) +++ trunk/sandbox/tobias/.classpath 2009-04-01 01:37:23 UTC (rev 6144) @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry excluding="com/ziclix/python/sql/|com/ziclix/python/sql/connect/|com/ziclix/python/sql/handler/|com/ziclix/python/sql/pipe/|com/ziclix/python/sql/pipe/csv/|com/ziclix/python/sql/pipe/db/|com/ziclix/python/sql/procedure/|com/ziclix/python/sql/resource/|com/ziclix/python/sql/util/" kind="src" path="jython/src"/> + <classpathentry kind="src" path="ssa/src"/> <classpathentry excluding="org/python/compiler/advanced/ast/" kind="src" path="compiler/src"/> - <classpathentry kind="src" path="util/src"/> + <classpathentry excluding="org/python/code/CodeTable.java|org/python/code/SpecializedCode.java|org/python/frame/JavaFrameAccessor.java" kind="src" path="util/src"/> <classpathentry kind="src" path="bytecode/src"/> <classpathentry kind="src" path="agent/src"/> <classpathentry kind="src" path="frame/src"/> Modified: trunk/sandbox/tobias/build.xml =================================================================== --- trunk/sandbox/tobias/build.xml 2009-04-01 00:07:49 UTC (rev 6143) +++ trunk/sandbox/tobias/build.xml 2009-04-01 01:37:23 UTC (rev 6144) @@ -56,7 +56,7 @@ <target name="setup target"> <mkdir dir="${target.dir}"/> </target> - <target name="clean" depends="clean jython,clean compiler,clean agent,clean bytecode,clean util,clean frame"> + <target name="clean" depends="clean jython,clean compiler,clean ssa,clean agent,clean bytecode,clean util,clean frame"> <delete dir="${target.dir}"/> </target> @@ -79,10 +79,23 @@ </ant> </target> - <target name="compiler" depends="setup target,jython,agent,util,bytecode"> + <target name="ssa"> + <echo>Building the SSA subproject</echo> + <ant dir="${basedir}/ssa" inheritAll="false"> + <property name="target.dir" location="${target.dir}"/> + </ant> + </target> + <target name="clean ssa"> + <ant dir="${basedir}/ssa" inheritAll="false" target="clean"> + <property name="target.dir" location="${target.dir}"/> + </ant> + </target> + + <target name="compiler" depends="setup target,jython,ssa,agent,util,bytecode"> <echo>Building the compiler subproject</echo> <ant dir="${basedir}/compiler" inheritAll="false"> <property name="jython.jar" location="${target.dir}/dist/jython-dev.jar"/> + <property name="ssa.jar" location="${target.dir}/ssa.jar"/> <property name="agent.jar" location="${target.dir}/agent-user.jar"/> <property name="antlr.jar" location="${target.dir}/dist/javalib/antlr-runtime-3.1.2.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-04-01 02:22:21
|
Revision: 6145 http://jython.svn.sourceforge.net/jython/?rev=6145&view=rev Author: thobes Date: 2009-04-01 01:45:35 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Added benchmarks. Added Paths: ----------- trunk/sandbox/tobias/tests/ trunk/sandbox/tobias/tests/functions.py trunk/sandbox/tobias/tests/parrotbench/ trunk/sandbox/tobias/tests/parrotbench/Makefile trunk/sandbox/tobias/tests/parrotbench/README.txt trunk/sandbox/tobias/tests/parrotbench/b.py trunk/sandbox/tobias/tests/parrotbench/b0.py trunk/sandbox/tobias/tests/parrotbench/b1.py trunk/sandbox/tobias/tests/parrotbench/b2.py trunk/sandbox/tobias/tests/parrotbench/b3.py trunk/sandbox/tobias/tests/parrotbench/b4.py trunk/sandbox/tobias/tests/parrotbench/b5.py trunk/sandbox/tobias/tests/parrotbench/b6.py trunk/sandbox/tobias/tests/parrotbench/t.py Added: trunk/sandbox/tobias/tests/functions.py =================================================================== --- trunk/sandbox/tobias/tests/functions.py (rev 0) +++ trunk/sandbox/tobias/tests/functions.py 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,23 @@ +def func(x): + z = x + +def bench(times): + for x in xrange(times): + func(x) + +def main(script, times='10000', warmups='20000', reps='3'): + from time import time + warmups = int(warmups); reps = int(reps); times = int(times) + for i in xrange(warmups): + bench(times) + res = [] + for i in xrange(reps): + t = time() + bench(times) + t = time() - t + res.append(t) + print min(res), max(res) + +if __name__ == '__main__': + import sys + main(*sys.argv) Property changes on: trunk/sandbox/tobias/tests/parrotbench ___________________________________________________________________ Added: svn:ignore + *.pyo *.pyc *.class out out? @out Added: trunk/sandbox/tobias/tests/parrotbench/Makefile =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/Makefile (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/Makefile 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,81 @@ +PYTHON= echo SPECIFY PYTHON +DIFF= diff +ECHO= echo +TIME= time +CMP= cmp +SCP= scp +RM= rm + +FILES= README.txt Makefile b.py b[0-9].py t.py out out[0-9] +TARFILE=parrotbench.tgz +TARGET= python.org:~ftp/pub/python/parrotbench/parrotbench.tgz + +time: + $(TIME) $(PYTHON) b.py >@out + $(CMP) @out out + +cmp: + $(PYTHON) -O b.py >@out + $(CMP) @out out + +diff: + $(PYTHON) -O b.py >@out + $(DIFF) @out out + +dist: $(TARFILE) + +$(TARFILE): $(FILES) + tar czf $(TARFILE) $(FILES) + +upload: dist + $(SCP) $(TARFILE) $(TARGET) + +clean: + -$(RM) -f @* *~ *.pyc *.pyo $(TARFILE) + +times: + for i in 0 1 2 3 4 5 6; do \ + $(ECHO) b$$i.py; \ + $(TIME) $(PYTHON) b$$i.py >@out$$i; \ + $(CMP) @out$$i out$$i; \ + done + +cmps: + for i in 0 1 2 3 4 5 6; do \ + $(ECHO) b$$i.py; \ + $(PYTHON) b$$i.py >@out$$i; \ + $(CMP) @out$$i out$$i; \ + done + +diffs: + for i in 0 1 2 3 4 5 6; do \ + $(ECHO) b$$i.py; \ + $(PYTHON) b$$i.py >@out$$i; \ + $(DIFF) @out$$i out$$i; \ + done + +all: out out0 out1 out2 out3 out4 out5 out6 + +out: b.py b?.py + $(PYTHON) -O b.py >out + +out0: b0.py + $(PYTHON) b0.py >out0 + +out1: b1.py + $(PYTHON) b1.py >out1 + +out2: b2.py + $(PYTHON) b2.py >out2 + +out3: b3.py + $(PYTHON) b3.py >out3 + +out4: b4.py b0.py + $(PYTHON) b4.py >out4 + +out5: b5.py + $(PYTHON) b5.py >out5 + +out6: b6.py + $(PYTHON) b6.py >out6 Added: trunk/sandbox/tobias/tests/parrotbench/README.txt =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/README.txt (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/README.txt 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,87 @@ +Parrot benchmark 1.0.4 +====================== + +[This is version 1.0.4, with a bugfix for the Mac OSX issue that Dan +reported, two further bugfixes for the dict ordering problem noted by +Samuele Pedroni, and an updated Makefile and t.py driver for Windows.] + +This is a benchmark to be run in front of a live audience at OSCON +2004 between Python and Parrot. The bytecode must be Python 2.3 +bytecode frozen in December 2003 (which is almost over as I write this +:-). + +For some more background, see the python-dev thread around + http://mail.python.org/pipermail/python-dev/2003-December/040977.html + +The benchmark here is intended to make Dan Sugalski's life difficult: +there are some standard benchmark thingies (simple random algorithms +using basic data types) but also a lot of play with odd corners of the +language definition, and Python's extremely dynamic object model: +funky descriptors, mutable classes, that sort of thing. The benchmark +is supposed to run with either Python 2.3 or Python 2.4. + +Brief description per file: + +Makefile -- Various ways of running the benchmark and sub-benchmarks. + +b.py -- The full benchmark output is defined as "python -O b.py". + +b0.py -- Lots of fun with a parser for a subset of Python (just + because this is a classic OO-heavy application). + +b1.py -- Explore recursion. Unbounded recursion is expected to raise + RuntimeError after about 1000 levels. (If Parrot supports much + more, this part will be slower; the point is to be able to + tweak the recursion limit.) + +b2.py -- Calculate PI using a generator. + +b3.py -- Sorting, and various ways of setting the comparison function + for list.sort(). + +b4.py -- Another test for the code from b0.py, this time with code + derived from Python 2.3's heapq.py. + +b5.py -- Test the standard library, including three standard Unicode + codecs (ASCII, Latin-1 and UTF-8), various descriptors, and + mutable classes. + +b6.py -- Check speed of iterating over several common iterators. + +Note that per agreement I'm not allowed to use any built-in extension +modules, not even __builtin__ or sys. This means there's no access to +sys.args (so no command line arguments), sys.stdout (but we have +"print >>file") or to sys.exc_info(). Dan could save some nanoseconds +by not supporting tracebacks. But that would be cheating. Also +cheating would be to do all the work at compile time (this is +theoretically possible since the program has no input). + +Per agreement the following builtins are out: open(), file(), input(), +raw_input(), compile(), eval(), execfile(), and the exec statement. +But I assume the print statement is okay (the program must communicate +its success or failure *somehow*). + +I'm being nice, and am voluntarily refraining from using __builtins__, +basestring, callable(), __import__(), reload(), dir(), globals(), +locals(), vars(), help(), apply(), buffer(), coerce(), or intern(). +I'm also not digging around in the func_code attribute of function +objects. + +On the use of __debug__: this is a built-in variable, set to True +normally and to False when Python is invoked with -O. I use this to +produce verbose output without -O but minimal output with it. For the +actual benchmark, Python should use -O, and Dan can simply set +__debug__ to False in the builtins if he prefers. + +On timing: there's a requirement that the benchmark runs for at least +30 seconds. It currently runs for nearly a minute on my home box, +which is a four-year-old 650 MHz Pentium box. If the contest hardware +is so fast that it runs under a minute, there's a number in b.py that +can be cranked up to increase the number of runs. (It takes 27 +seconds on my recent work desktop, and on my screaming IBM T40 laptop +it runs in 15 seconds, so I suspect that we should at least double the +number of runs from 2 to 4.) + +December 31, 2003, + +--Guido van Rossum (home page: http://www.python.org/~guido/) Added: trunk/sandbox/tobias/tests/parrotbench/b.py =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/b.py (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/b.py 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,46 @@ +import b0 +import b1 +import b2 +import b3 +import b4 +import b5 +import b6 + +import sys +from time import time + +WARMUP = 0 +TIMES = 3 +NUMBER = 1 +ITERATIONS = 1 + +def run(module, iteration): + print >>sys.stderr, "-->", module.__name__ + res = [] + for i in range(TIMES): + t = time() + for i in range(NUMBER): + module.main() + t = time() - t + res.append(t/NUMBER) + return res + +if 'java' in sys.platform: + def run(module, iteration, run=run): + if not iteration: + for i in range(WARMUP): + module.main() + return run(module, iteration) + +def main(): + t = time() + for i in range(ITERATIONS): + print >>sys.stderr, "--> iteration", i + for module in (b0, b2, b3, b4, b5, b6): # b1 ommitted + mt = min(run(module, i)) + print >>sys.stderr, "best of 3:", mt + t = time() - t + print >>sys.stderr, "--> All done.", t + +if __name__ == '__main__': + main() Added: trunk/sandbox/tobias/tests/parrotbench/b0.py =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/b0.py (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/b0.py 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,938 @@ +def check(a, b): + if not a == b: + raise AssertionError("%.30r != %.30r" % (a, b)) + +def proto___new__(cls, name): + if name in cls.name2num: + return cls.name2num[name] + cls.name2num[name] = obj = int.__new__(cls, cls.next) + cls.num2name[obj] = name + cls.next += 1 + return obj + +def proto___repr__(self): + return self.__class__.num2name[self] + +class MetaToken(type): + def __new__(metacls, name, bases, vars): + cls = type.__new__(metacls, name, bases, vars) + cls.__new__ = staticmethod(proto___new__) + cls.__repr__ = cls.__str__ = proto___repr__ + cls.next = 0 + cls.name2num = {} + cls.num2name = {} + return cls + +Token = MetaToken('Token', (int,), {}) + +EOF = Token('EOF') +INDENT = Token('INDENT') +DEDENT = Token('DEDENT') +NEWLINE = Token('NEWLINE') +NAME = Token('NAME') +NUMBER = Token('NUMBER') +STRING = Token('STRING') +OPERATOR = Token('OPERATOR') + +class Scanner(object): + + # A vaguely Pythonic tokenizer + + def __init__(self, getc): + self.getc = getc + self.indents = [0] + + def tokenize(self, + eolchars = ('', '\r', '\n'), + quotes = ('"', '\''), + hspaces = (' ', '\t'), + longops = dict.fromkeys( + ('<<', '>>', '<=', '>=', '==', '!=', '//', '**'))): + # A generator yielding successive tokens to the parser + # Each token is a (tokentype, value) pair + getc = self.getc + nextc = getc() + while True: + col = 0 + while nextc.isspace(): + if nextc == '\t': + col = ((col//8) + 1)*8 + elif nextc == ' ': + col += 1 + else: + col = 0 # \f, \v, \r, \n all reset the column + nextc = getc() + if nextc == '#': + while nextc not in eolchars: + nextc = getc() + continue + if col != self.indents[-1]: + while col < self.indents[-1]: + yield DEDENT, '' + del self.indents[-1] + # This will yield DEDENT + INDENT for inconsistent dedent + if col > self.indents[-1]: + yield INDENT, '' + self.indents.append(col) + while nextc not in eolchars: + if nextc.isalpha() or nextc == '_': + name = '' + while nextc.isalnum() or nextc == '_': + name += nextc + nextc = getc() + yield NAME, name + elif nextc.isdigit(): + number = '' + while nextc.isdigit(): + number += nextc + nextc = getc() + yield NUMBER, number + elif nextc in quotes: + quote = nextc + s = nextc + nextc = getc() + while nextc != quote: + if nextc in eolchars: + if not nextc: + raise SyntaxError("EOF in string") + raise SyntaxError("unescaped %r in string" % nextc) + s += nextc + if nextc == '\\': + nextc = getc() + s += nextc + nextc = getc() + s += nextc + nextc = getc() + yield STRING, s + elif nextc == '#': + while nextc not in eolchars: + nextc = getc() + elif nextc in hspaces: + nextc = getc() + else: + c1 = nextc + nextc = getc() + if c1+nextc in longops: + c2 = nextc + nextc = getc() + yield OPERATOR, c1+c2 + else: + yield OPERATOR, c1 + yield NEWLINE, '' + nextc = getc() + if not nextc: + while self.indents[-1]: + yield DEDENT, '' + del self.indents[-1] + break + yield EOF, '' + +class Link(object): + __slots__ = ['value', 'next'] + def __init__(self): + self.value = None + self.next = None + +class Clone(object): + __slots__ = ['link', 'itnext'] + def __init__(self, it, link=None): + if isinstance(it, Clone): + self.itnext = it.itnext + self.link = it.link + else: + self.itnext = it.next + self.link = Link() + def __iter__(self): + return self + def next(self): + next = self.link.next + if next is None: + self.link.value = value = self.itnext() + self.link.next = next = Link() + else: + value = self.link.value + self.link = next + return value + +def getcFromString(s): + for c in s: + yield c + while True: + yield '' + +sample = ''' +def pi(): + # Compute digits of Pi. Algorithm due to LGLT Meertens. + k, a, b, a1, b1 = 2, 4, 1, 12, 4 + while 1: + p, q, k = k*k, 2*k+1, k+1 + a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 + d, d1 = a//b, a1//b1 + while d == d1: + yield d + a, a1 = 10*(a%b), 10*(a1%b1) + d, d1 = a//b, a1//b1 +def strhash(s): + # Python 2.x string hash algorithm + if s == '': + return 0 + x = ord(s[0])<<7 + for c in s: + x = ((1000003*x) ^ ord(c)) & 4294967295 # 0xffffffff + return x^len(s) +''' + +operators = { + '<': 1, + '<=': 1, + '==': 1, + '!=': 1, + '>': 1, + '>=': 1, + '|': 2, + '^': 3, + '&': 4, + '<<': 5, + '>>': 5, + '+': 6, + '-': 6, + '*': 7, + '/': 7, + '//': 7, + '%': 7, + '**': 8, +} + +dispatch = { + '<': lambda x, y: x < y, + '<=': lambda x, y: x <= y, + '==': lambda x, y: x == y, + '!=': lambda x, y: x != y, + '>': lambda x, y: x > y, + '>=': lambda x, y: x >= y, + + '|': lambda x, y: x | y, + '^': lambda x, y: x ^ y, + '&': lambda x, y: x & y, + '<<': lambda x, y: x << y, + '>>': lambda x, y: x >> y, + + '+': lambda x, y: x + y, + '-': lambda x, y: x - y, + + '*': lambda x, y: x * y, + '/': lambda x, y: x / y, + '%': lambda x, y: x % y, + '//': lambda x, y: x // y, + + '**': lambda x, y: x ** y, + } + +class DoReturn(Exception): + def __init__(self, value=None): + self.value = value + +class DoBreak(Exception): + pass + +def eval(body, globals, locals): + for stmt in body: + stmt.eval(globals, locals) + +def geneval(body, globals, locals): + for stmt in body: + for value in stmt.geneval(globals, locals): + yield value + +def isgenerator(body): + for stmt in body: + if stmt.isgenerator(): + return True + return False + +class Dict(dict): + + def __repr__(self): + keys = self.keys() + keys.sort() + L = [] + for key in keys: + L.append(repr(key) + ": " + repr(self[key])) + return "{" + ", ".join(L) + "}" + +class Function(object): + makeLocals = Dict + def __init__(self, name, args, body, globals): + self.name = name + self.args = args + self.body = body + self.globals = globals + def __call__(self, *args): + check(len(args), len(self.args)) + locals = self.makeLocals(zip(self.args, args)) + try: + eval(self.body, self.globals, locals) + except DoReturn, exc: + return exc.value + +class Generator(Function): + def __call__(self, *args): + check(len(args), len(self.args)) + locals = self.makeLocals(zip(self.args, args)) + try: + for value in geneval(self.body, self.globals, locals): + yield value + except DoReturn, exc: + if exc.value is not None: + raise RuntimeError("'return' with argument in generator") + return + +class Node(object): + def isgenerator(self): + return False + def geneval(self, globals, locals): + self.eval(globals, locals) + if False: + yield None +class Define(Node): + def __init__(self, name, args, body): + self.name = name + self.args = args + self.body = body + def __repr__(self): + return "%s(%r, %r, ...)" % (self.__class__.__name__, + self.name, self.args) + def eval(self, globals, locals): + if isgenerator(self.body): + obj = Generator(self.name, self.args, self.body, globals) + else: + obj = Function(self.name, self.args, self.body, globals) + globals[self.name] = obj +class For(Node): + def __init__(self, var, seq, body): + self.var = var + self.seq = seq + self.body = body + def __repr__(self): + return "%s(%r, %r, ...)" % (self.__class__.__name__, + self.var, self.seq) + def eval(self, globals, locals): + for value in self.seq.eval(globals, locals): + self.var.assign(value, globals, locals) + try: + eval(self.body, globals, locals) + except DoBreak: + break + def geneval(self, globals, locals): + for value in self.seq.eval(globals, locals): + self.var.assign(value, globals, locals) + try: + for v in geneval(self.body, globals, locals): + yield v + except DoBreak: + break +class While(Node): + def __init__(self, test, body): + self.test = test + self.body = body + def __repr__(self): + return "%s(%r, ...)" % (self.__class__.__name__, self.test) + def isgenerator(self): + return isgenerator(self.body) + def eval(self, globals, locals): + while self.test.eval(globals, locals): + try: + eval(self.body, globals, locals) + except DoBreak: + break + def geneval(self, globals, locals): + while self.test.eval(globals, locals): + try: + for value in geneval(self.body, globals, locals): + yield value + except DoBreak: + break +class If(Node): + def __init__(self, test, body, elsebody=None): + self.test = test + self.body = body + self.elsebody = elsebody + def __repr__(self): + return "%s(%r, ...)" % (self.__class__.__name__, self.test) + def isgenerator(self): + return isgenerator(self.body) or (self.elsebody is not None and + isgenerator(self.elsebody)) + def eval(self, globals, locals): + if self.test.eval(globals, locals): + eval(self.body, globals, locals) + elif self.elsebody is not None: + eval(self.elsebody, globals, locals) + def geneval(self, globals, locals): + if self.test.eval(globals, locals): + for value in geneval(self.body, globals, locals): + yield value + elif self.elsebody is not None: + for value in geneval(self.elsebody, globals, locals): + yield value +class Return(Node): + def __init__(self, expr=None): + self.expr = expr + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.expr) + def eval(self, globals, locals): + if self.expr is None: + value = None + else: + value = self.expr.eval(globals, locals) + raise DoReturn(value) +class Yield(Node): + def __init__(self, expr): + self.expr = expr + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.expr) + def isgenerator(self): + return True + def geneval(self, globals, locals): + if self.expr is None: + value = None + else: + value = self.expr.eval(globals, locals) + yield value +class Break(Node): + def __repr__(self): + return "%s()" % (self.__class__.__name__,) + def eval(self, globals, locals): + raise DoBreak() +class Print(Node): + def __init__(self, exprs): + if not isinstance(exprs, list): + exprs = [exprs] + self.exprs = exprs + def eval(self, globals, locals): + for e in self.exprs: + print e.eval(globals, locals), + print +class Assign(Node): + def __init__(self, lhs, expr): + self.lhs = lhs + self.expr = expr + def __repr__(self): + return "%s(%r, %r)" % (self.__class__.__name__, self.lhs, self.expr) + def eval(self, globals, locals): + value = self.expr.eval(globals, locals) + for v in self.lhs: + v.assign(value, globals, locals) +class Exprs(Node): + def __init__(self, exprs): + self.exprs = exprs + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.exprs) + def eval(self, globals, locals): + return tuple([e.eval(globals, locals) for e in self.exprs]) + def assign(self, value, globals, locals): + if len(self.exprs) != len(value): + raise TypeError("multi-assign length mismatch") + for e, v in zip(self.exprs, value): + e.assign(v, globals, locals) +class Binop(Node): + def __init__(self, left, op, right): + self.left = left + self.op = op + self.right = right + self.opeval = dispatch[self.op] + def __repr__(self): + return "%s(%r, %r, %r)" % (self.__class__.__name__, + self.left, self.op, self.right) + def eval(self, globals, locals): + return self.opeval(self.left.eval(globals, locals), + self.right.eval(globals, locals)) +class Attribute(Node): + def __init__(self, expr, name): + self.expr = expr + self.name = name + def __repr__(self): + return "%s(%r, %r)" % (self.__class__.__name__, self.expr, self.name) + def eval(self, globals, locals): + v = self.expr.eval(globals, locals) + return getattr(v, self.name) +class Index(Node): + def __init__(self, expr, index): + self.expr = expr + self.index = index + def __repr__(self): + return "%s(%r, %r)" % (self.__class__.__name__, self.expr, self.index) + def eval(self, globals, locals): + v = self.expr.eval(globals, locals) + return v[self.index.eval(globals, locals)] + def assign(self, value, globals, locals): + v = self.expr.eval(globals, locals) + v[self.index.eval(globals, locals)] = value +class Call(Node): + def __init__(self, expr, args): + if not isinstance(args, list): + args = [args] + self.expr = expr + self.args = args + def __repr__(self): + return "%s(%r, %r)" % (self.__class__.__name__, self.expr, self.args) + def eval(self, globals, locals): + f = self.expr.eval(globals, locals) + args = [a.eval(globals, locals) for a in self.args] + return f(*args) +class Literal(Node): + def __init__(self, literal): + self.literal = literal + self.value = self.evalit() + def eval(self, globals, locals): + return self.value + def __repr__(self): + return "%s(%r)" % (self.__class__.__name__, self.literal) +simple_escapes = {"a": "\a", + "b": "\b", + "f": "\f", + "n": "\n", + "r": "\r", + "t": "\t", + "v": "\v", + "'": "'", + '"': '"', + "\\": "\\"} +class String(Literal): + def evalit(self, octals='01234567'): + s = self.literal[1:-1] + if '\\' not in s: + return s + L = [] + it = iter(range(len(s))) + for i in it: + c = s[i] + if c != '\\': + L.append(c) + else: + i = it.next() + c = s[i] + if c == 'x': + if i+2 >= len(s): + raise ValueError("incomplete \\x escape in string") + d1 = s[it.next()] + d2 = s[it.next()] + L.append(chr(int(d1+d2, 16))) + elif c in octals: + if i+1 < len(s) and s[i+1] in octals: + c += s[it.next()] + if i+2 < len(s) and s[i+2] in octals: + c += s[it.next()] + L.append(chr(int(c, 8))) + else: + L.append(simple_escapes.get(c, '\\' + c)) + return "".join(L) +class Number(Literal): + def evalit(self): + return int(self.literal) +class Name(Node): + def __init__(self, name): + self.name = name + def __repr__(self): + return "Name(%r)" % self.name + def eval(self, globals, locals): + if self.name in locals: + return locals[self.name] + if self.name in globals: + return globals[self.name] + if self.name == 'ord': + return ord + if self.name == 'len': + return len + raise NameError(self.name) + def assign(self, value, globals, locals): + locals[self.name] = value + +class Parser(object): + def __init__(self, scanner): + self.scanner = scanner + self.nexttoken() + def nexttoken(self): + self.token, self.value = rv = self.scanner.next() + ##print rv + return rv + def expect(self, token, value=None): + if self.token != token: + raise SyntaxError + if value is not None and self.value != value: + raise SyntaxError + value = self.value + self.nexttoken() + return value + def parse(self): + stmts = [] + while self.token != EOF: + stmts.append(self.parse_stmt()) + return stmts + def parse_stmt(self, + keywords=('def', 'for', 'while', 'if', + 'print', 'return', 'yield', 'break')): + if self.value in keywords: + return getattr(self, 'parse_' + self.value)() + else: + return self.parse_simple() + def parse_def(self): + self.expect(NAME, 'def') + name = self.expect(NAME) + self.expect(OPERATOR, '(') + args = [] + if self.value != ')': + args.append(self.expect(NAME)) + while self.value == ',': + self.nexttoken() + args.append(self.expect(NAME)) + self.expect(OPERATOR, ')') + self.expect(OPERATOR, ':') + self.expect(NEWLINE) + body = self.parse_body() + return Define(name, args, body) + def parse_for(self): + self.expect(NAME, 'for') + var = self.parse_expr() + self.expect(NAME, 'in') + seq = self.parse_expr() + self.expect(OPERATOR, ':') + self.expect(NEWLINE) + body = self.parse_body() + return For(var, seq, body) + def parse_while(self): + self.expect(NAME, 'while') + test = self.parse_expr() + self.expect(OPERATOR, ':') + self.expect(NEWLINE) + body = self.parse_body() + return While(test, body) + def parse_if(self): + self.expect(NAME, 'if') + test = self.parse_expr() + self.expect(OPERATOR, ':') + self.expect(NEWLINE) + body = self.parse_body() + if self.value != 'else': + elsebody = None + else: + self.expect(NAME, 'else') + self.expect(OPERATOR, ':') + self.expect(NEWLINE) + elsebody = self.parse_body() + return If(test, body, elsebody) + def parse_body(self): + self.expect(INDENT) + body = [self.parse_stmt()] + while self.token != DEDENT: + body.append(self.parse_stmt()) + self.expect(DEDENT) + return body + def parse_print(self): + self.expect(NAME, 'print') + exprs = self.parse_exprs() + self.expect(NEWLINE) + return Print(exprs) + def parse_return(self): + self.expect(NAME, 'return') + if self.token == NEWLINE: + e = None + else: + e = self.parse_exprs() + self.expect(NEWLINE) + return Return(e) + def parse_yield(self): + self.expect(NAME, 'yield') + e = self.parse_exprs() + self.expect(NEWLINE) + return Yield(e) + def parse_break(self): + self.expect(NAME, 'break') + self.expect(NEWLINE) + return Break() + def parse_simple(self): + e = self.parse_exprs() + if self.value == '=': + lhs = [] + while self.value == '=': + self.nexttoken() + lhs.append(e) + e = self.parse_exprs() + self.expect(NEWLINE) + return Assign(lhs, e) + else: + self.expect(NEWLINE) + return e + def parse_exprs(self): + e = self.parse_expr() + if self.value != ',': + return e + exprs = [e] + while self.value == ',': + self.nexttoken() + exprs.append(self.parse_expr()) + return Exprs(exprs) + def parse_expr(self, prio=0): + left = self.parse_term() + while self.value in operators and operators[self.value] > prio: + op = self.expect(OPERATOR) + right = self.parse_expr(operators[op]) + left = Binop(left, op, right) + return left + def parse_term(self): + t = self.parse_atom() + while self.value in ('.', '[', '('): + if self.value == '.': + self.nexttoken() + name = self.expect(NAME) + t = Attribute(t, name) + elif self.value == '[': + self.nexttoken() + index = self.parse_exprs() + self.expect(OPERATOR, ']') + t = Index(t, index) + elif self.value == '(': + self.nexttoken() + if self.value == ')': + args = [] + else: + args = self.parse_exprs() + if isinstance(args, Exprs): + args = args.exprs + self.expect(OPERATOR, ')') + t = Call(t, args) + else: + raise AssertionError("shouldn't get here") + return t + def parse_atom(self): + if self.value == '(': + self.nexttoken() + exprs = self.parse_exprs() + self.expect(OPERATOR, ')') + return exprs + if self.token is STRING: + return String(self.expect(STRING)) + if self.token is NAME: + return Name(self.expect(NAME)) + if self.token is NUMBER: + return Number(self.expect(NUMBER)) + raise SyntaxError + +class List(list): + __setitem__ = list.__setitem__ + __getitem__ = list.__getitem__ + +class Str(str): + __getitem__ = str.__getitem__ + +class OutputFile(object): + def __init__(self): + self.data = [] + self.softspace = True + reset = __init__ + def write(self, s): + self.data.append(s) + def getvalue(self): + r = "".join(self.data) + self.data = List() + return r + +output = OutputFile() + +def cleanup(s): + s = str(s).replace('<__main__.', '<').replace('<b0.', '<') + i = s.find(' at 0x') + while i > 0: + j = s.find('>', i+6) + if j < 0: + break + digits = s[i+4:j] + try: + number = int(digits, 0) + except ValueError: + break + else: + s = s[:i+5] + s[j:] + i = s.find(' at 0x') + return s + +def write(s): + s = cleanup(s) + if __debug__: + print s, + print >>output, s, + +def writeln(s=''): + write(str(s) + '\n') + +def myhash(s, ord=ord): + if not s: + return 0 + x = ord(s[0])<<7 + for c in s: + x = ((1000003*x) ^ ord(c)) & 0xffffffffL + return x^len(s) + +def checkoutput(n=0): + outputtext = output.getvalue() + check(strhash(outputtext), n) + +strhash = myhash + +indent = "" + +def instrumentClass(cls): + cname = cls.__name__ + '.' + for name in cls.__dict__: + if name == '__dict__': + continue + descr = cls.__dict__[name] + if hasattr(descr, '__get__'): + setattr(cls, name, instrumentDescriptor(cname+name, descr)) + +def unInstrumentClass(cls): + for name in cls.__dict__: + descr = cls.__dict__[name] + if isinstance(descr, instrumentDescriptor): + setattr(cls, name, descr.obj) + +class instrumentDescriptor(object): + def __init__(self, name, obj): + self.name = name + self.obj = obj + def __get__(self, *args): + result = self.obj.__get__(*args) + if not hasattr(result, '__call__'): + return result + return instrumentCall(self.name, result) + +class instrumentCall(object): + def __init__(self, name, obj): + self.name = name + self.obj = obj + def __call__(self, *args): + global indent + oldindent = indent + try: + indent = indent + " " + argreprs = map(repr, args) + for i, s in enumerate(argreprs): + s = cleanup(s) + if len(s) >= 45: + s = s[:20] + "..." + s[-20:] + argreprs[i] = s + writeln(indent + "%s(%r)" % (self.name, ", ".join(argreprs))) + try: + result = self.obj(*args) + except Exception, exc: + writeln(indent + "raise %r" % (exc,)) + raise + else: + if result is None: + writeln(indent + "return") + else: + writeln(indent + "return %r" % (result,)) + return result + finally: + indent = oldindent + +def instrumentTree(base): + instrumentClass(base) + for cls in base.__subclasses__(): + instrumentTree(cls) + +def unInstrumentTree(base): + unInstrumentClass(base) + for cls in base.__subclasses__(): + unInstrumentTree(cls) + +def main(): + output.reset() + + s = Scanner(getcFromString(sample).next) + it = Clone(s.tokenize()) + it2 = Clone(it) + L = [] + for pair in it: + L.append(pair) + L2 = list(it2) + check(L, L2) + + scanner = Scanner(getcFromString(sample).next).tokenize() + parser = Parser(scanner) + instrumentClass(Parser) + root = parser.parse() + + checkoutput(1413352820) + + env = Dict() + eval(root, env, env) + g = env['pi']() + for i in range(1000): + write(g.next()) + writeln('') + strhash = env['strhash'] + + for x in '', 'x', 'abc', 'abc'*100: + check(strhash(x), myhash(x)) + + strhash = myhash + checkoutput(3960406533) + + it = Clone(getcFromString(unicode(sample, "utf8"))) + it2 = Clone(it) + scanner = Scanner(it.next).tokenize() + parser = Parser(scanner) + root = parser.parse() + checkoutput(3827423707)#checkoutput(1308798191) + env = Dict() + eval(root, env, env) + g = env['pi']() + for i in range(1000): + write(g.next()) + writeln() + checkoutput(3960406533) + + instrumentTree(Node) + scanner = Clone(Scanner(it2.next).tokenize()) + scanner2 = Clone(scanner) + parser = Parser(scanner) + root = parser.parse() + checkoutput(3257889492) + env = Dict() + eval(root, env, env) + g = env['pi']() + digits = [] + for i in range(10): + digits.append(g.next()) + checkoutput(2705414689)#checkoutput(3259608361) + print "".join(map(str, digits)) + + unInstrumentTree(Node) + unInstrumentClass(Parser) + parser = Parser(scanner2) + root = parser.parse() + checkoutput(0) + env = Dict() + eval(root, env, env) + g = env['pi']() + digits = [] + for i in range(10): + digits.append(g.next()) + print "".join(map(str, digits)) + out2 = output.getvalue() + checkoutput(0) + + class TrackingDict(Dict): + def __setitem__(self, *args): + writeln("%s = %.50r" % args) + super(TrackingDict, self).__setitem__(*args) + Function.makeLocals = TrackingDict + g = env['pi']() + digits = [] + for i in range(100): + digits.append(g.next()) + checkoutput(902386495) + Function.makeLocals = Dict + +if __name__ == '__main__': + main() Added: trunk/sandbox/tobias/tests/parrotbench/b1.py =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/b1.py (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/b1.py 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,37 @@ +def depth0(n): + try: + n = depth0(n+1) + except RuntimeError: + pass + return n + +def depth1(n, pea): + p = (pea, pea) + for i in xrange(n): + p = (p, pea) + try: + n, p = depth1(n+1, p) + except RuntimeError: + pass + return n, p + +def main(): + print depth0(0) >= 996 + pea = [] + base, p = depth1(0, pea) + print base >= 996 + pea.append(p) + while p[1] is not pea: + q = p[1] + n = 0 + while p[1] is q: + n += 1 + p = p[0] + if n != base+1: + raise RuntimeError, (n, base) + base -= 1 + print base + del pea[:] + +if __name__ == '__main__': + main() Added: trunk/sandbox/tobias/tests/parrotbench/b2.py =================================================================== --- trunk/sandbox/tobias/tests/parrotbench/b2.py (rev 0) +++ trunk/sandbox/tobias/tests/parrotbench/b2.py 2009-04-01 01:45:35 UTC (rev 6145) @@ -0,0 +1,43 @@ +def izip(*args): + args = map(iter, args) + while 1: + yield tuple([x.next() for x in args]) + +class PI(object): + def __iter__(self): + k, a, b, a1, b1 = 2, 4, 1, 12, 4 + while 1: + p, q, k = k*k, 2*k+1, k+1 + a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1 + d, d1 = a//b, a1//b1 + while d == d1: + yield d + a, a1 = 10*(a%b), 10*(a1%b1) + d, d1 = a//b, a1//b1 + self.a1 = a1 + +tests = { + 99: 44251238236192885942548145627920559612834490019477028496725657079267312460031559302172150714110203307954379217477379106929168768496503354540899921113305213841256909892518928098307564463751633347248940009920269109969147590732355948788056064000000000000000000000000000000000, + 199: 1000596230862142822590229503409372398669386421051058756167623955196210292140473223995201364067656314884093070923379776058593112593572415388874119773448702613069929696236969954099574382312021625484547051647005317079077091903572365445691946982207111619679684359784089545801152269560862321544414943514190096631259179363627029133476495865659666812167626608236901769581685802712761140555948794720353924341042650072696819415055421183957924869318180281662429407332762869255321912813711898750492786968744984544308467386273640507277517829133760299081875243110913120665600000000000000000000000000000000000000000000000000000000000000000, + 299: 21435887192948215614003242240833359745116667655295850182859413191163731683078952650094326080502769326477126925083216343548170734614172935170340269921309820711302999200539819947867212813551107194027554006207604344128185286047718105667902068109038526051946371288160859880626765253522805513232333491975220030085760604224065673379016506268781757490866758397031010384977255107445504115787686395015630645137203786798858795200871880590717053675063928230569710372699708910775901232998621866511805494494875255496291270721486641615650345940568291905806263698337995119757061129615716444504290546816572960918445558805410505143000167480199333531897643812998836381668261331434305825321676717544726859895857274900170645624087291170408290210800888136650695682668742663263729788760787553650802761860581841523193434651375248115751262481847514479478467508156570863734207165375573520453327647345580868727572348946580766720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 399: 8561869806834798989612544773400323313179941907807794568262440743112858898989689026704576126118595731944427372856665962019724479801384062969795859298394962551328689077803363555807984316902252940902014889926277022833163566635584197843427728248130112186455323888931447608868707068434776186855353396855833436850229162071581300162579548898284489248532968742303181986647234058212952485789589428331561779973912890270787218670895308761530690791268509970600822462460658693835169935042766248145148420454545182598329186640466821688459819069501551463819641554408111110110151692239551586768176506251155525099233988638762885805917822379263713549352362861698409524070686169569736102177070749091831233867352657647277185192372387156966362270318951122024815096048593017226290871189781143762422618457018186519922454408157004798904710507709224018924427721086955924703838793251170380074666507887931281809304737450536142489860864008197549841329444837980614206463968734383477281485253049376604442937718053220015067951581390345559841730246517326234188422995410478560583662283465682728995404843025593838691776410644612449087517702830166590175727603809091974002341560317871295071902646575676785149353532452189474547463794343581915053692213809212940949327454179290314595392041251528682462248960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 499: 76766108631940210937325132198465864457610296920889901883030849944249491732767613231460026747961565950406551576277982908797232709115573397680840144587889878137072051513231549168224623486940739011824470282874235014299280185292476357855772342908560617765615433859648152443400651562464645577267133565969609608350684571285655853054712724572601634219899681603288076555568556603519768176952205317390973803424356164269999588467102540378584128532600037700811666341008358928602746642205050531572408717173194538376392544677893444983399212894400285344939556094505296780409965886324800278706769664438849417755796690865276144102933659458633433715362955199895852120250371111523601408509601075849463319256275384860431711268141908667883149791804139967338545358206127158990156425480764804297397170597657279674744907448120365194723760375846968550637839625396799787981542068069955660525855300927415620426941417314885401820985001913260101401230309399239801959598342546866307638278153091955749126275448041244876145703346573865766318100310570772620069178810413227974410262538853025115028173981758758325369986648321051017250246765567173447382346682177940131720445933725662183060319023268847648849199144024316405375647697684691770109145226746285626861260128121857903981514928439560981950894568063766637808949718925624322085933716705575498276564370619232206346293654148202964613950060056885972213718288213503135634713342418000998239413319648014225323725957085146390629354204147053598603318165064363587092287902579232811848133423379877761425679796787506376625832936596918827500201870173625427859893528696839243761272981017048564872611531028386533983068887010900245332623360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 599: 2120272365916624093549573503339645760249925590629691905298380620826238336680485250775748238851715242513568106491781607325637843266230182543159994052803483210198817868787245904539293723939615230218367927170630181008508608682473786334989642773309671087946382125393064054429291378005365307369932354974406782493586482693959468507929142578311374952191246685196652549840632791830721769718961140786765636611636126263231624375986806336404014991356931344468888703169171934706250411475009307785661110741777527324954571089817794240318090318731138065871311050896639596947512824176632981670282022349794742982306588866780679141100000979482012703431996529614153969006965379857532250140411692707925832547131496348527554204126276904033851312192294719407040113066259294928824359144110570802157647067643172691886034509485269315724734491380423529629749223874238867299576969461404272650055836211201773406419214625694511195241201118512536217548368603119794507877569790693417734860149658615068452866115479874379764219274786787905887717695084355702688921163181942859261931462396527992761425892799259213253073620895655262890187342553757398412577032172382168869416402722279336223791913538036339921582169629706204936615017408331600286347593291767969984872197163003714688529499720018226023559039421196525971154371211007274491079331581462202803270308044945895467086216358487714539723075423709132632711104176237158591348264918119231549610638101215271635751068862184966089290055162842592702917037089658541420657556777630476720227083286444062812384078931053717097690428021828828314330897267550018034334466896893522629282170940447351039396227633740743904716345874216287187030893375694818646093977919289909500326805873535353890952168548557367192114315242338374030375201461534835392764765715654233759268109399742689152068054720118040413609079726305828412608467329058007828176699982184798481881032984952414016677410029974950886156526807807461864142760141455419659333722571838033134676308170730229830331659493070917764742995587861083129433623003009634591950055674021412864000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 699: 54571787430958399400005671895793395810514965360222657069233155257869831245514703898329984842599345345797192550495348877752750716462799995262238897879189712362792599540276947290240369738995122870036473426596166137781512133732841079442335809215673962548136751501962395101508082458022910749004870763777751025686143054266560789699467897488208314352497922931109255090615845989365253963697070552088326927571730238674587343725408556548847027815257453311184273200959063948470485405418687785822617652671609706936044865165112267634536255942342137737568633616435112070199187087675353099732490445262584463118808715533880843287282323502172455874549895164201021082781039664171931972950867328706112021059604060340338606871763348783573247509755207096610318069014034226371127241365822041636184401808035853347524245498756203483212762819194058857286022123510755206330238728338540936417830717262921800876426685863489447721974523840880601732138137563579815785444094205972614263669956513740906383728059662729451143837852557411654864608820606495589950458165214874335528071914274226508583618548221498046257433189345079263951024381261213067438755400772554918420156611989161275819373340626340095277962552853128100524758416265525218190626769969209796740560920753972479878773975562043659464796071536492340776053077906431346958246988865607675041671683462291933241209943247185229400300531069434821908210393754215270727867860747889887039965048681895147820192799637449521165944356200714071125353390157596677223069290303004608406259263260481747075716421783084148765931010321931117509077808771925529544210503591442107960112359151446110353540208471607107935843590192610650273333834161753099980189676608843057569018657095864002224328579690446259626925339472680838762568611923981193711770106009098171810029820020455115170724929203588390317815053369572788421300357832205199443876759544538582639402241883694827090801385537555747373037489025563879252287165075989079784157761408131323383708336366882662138204724992104184118234360573248835518448645547172342375665655653335218281979099552819760633230580536381778069677840715358530867566196795457417775340310424672192141977398974880862555283206621628790868960591215870136675469162920111812154003932444777532696287441691534774646863311895804406055064912499462089287403059782748799895590902455779428144219297715674077436643273687702239680646741926247202392605642085420467071089682849156330161168666278561180452156752478501391564800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 799: 1165019969951028145448474870606694745628445847100063691175045426809524271280385211025149309439736889668431363205043295468478227885516089826430304252028412665878074268391689531376676369814346541259212014204219732753532556283167763492813491981617042686520428375483043823229347180225027527767892288494222400268347648277077085092324780438909293027666621101974271603717458184633691745699246613625445708958093814173789616468299755424767037016330877693069425266688538600904598289113523091543776886739998104937757229618512461155015780709364046160704463608630709906484636013448672656426886594747044346764985843639265457373603772739772415706169602575546300922342271055004256781082363315561913547648640954959000371679492600850323235849380042831378495135583566599574416729516620087245906062795758387578224336805373895492794645806096068657974185136831114580747646909717985162654700150389838526549868770885629372149350446773860669388038471776557526515910033467628431871878316408982723876203877207112913665539371348724351835198296871265983857890498623536324848877236019869092878781427110113542625110041789002286754615039920319343770043455657828924442170211652589212117516714709894518726603532996156030790024814913146519305169722564850597797774298352669973544466122022123500758687471133096300448171087716127901248915474363042779227724255413335477296839171260050411230913787907606725169016351209025747882086625397286625248376528998919634710302520393941530723973487259019187136668425367426482695231240294671376146585312211926447150542843171266291876037378067256463777431998792250381914496818845072319002851834894280540179694233589184751221721345515353061996569633890293841751623667699605067183984407638732497881628999347219982736106675680165842644133894916782230987223224828685930858657631697327168501437432678530579280064943872275218623486567776580213001821563007802859121520206862366831214550454660201924592069971928484116327345227633650931220240412989380696156101840018564700065411677388328804161110162279193672651278988425644004188569635636717470803677943610275223854671409519817008772946235477341217799495629951132446716193818794636841421507151304976152511616538200203214016457449981017869162192339882870379247422061597402496664647115346984746108902369843975335083490551753570803795438395111351577474760022446140821780548147639308232794984562286077490121188360571079033300272391145791202144846667875284539709679647945779713567130240017333648976286204155043105228295725874012316502327195124092416348347162737242449541649547547864777887315161229040122603297586496999009079092644539172087825680666618082263897443172558909377634579572489890372823889386192559147381373832288039653312458442917119615324859008094386594830981911977813106096806546361863080294950465184145762955879704231094550954751577536624215411479046060449038350499002129406780206980907086223769600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 899: 1961047400783793689152743738482061418112144594775859100963826903299941791245038595034363753615746408049289952725779309407444199325053710536522401903643581802543713504158806047235695705896380364921365885372696677158825553172792575130365677811577035805389273355225725863414284665498055318575649394451227797767110728923709058788425788790167032831982217805891947591307310391793051324726126078967699521915868839204118521519682024094610098117626863292184721906092521438801341497303557767071828077146885364536554032450624100316867547877010778603956083487035270791818649067384276377414249363983383717773036457804718062695046059095787213719308297709919175747285036636352990899483938970896812239613605956608649083554411609657838220544027128950682327843798882711829991989817881303883990647876969994768271897974773455464646523348820392471256024577102382204328939384060235197563409904986708133897802121211859685551906620747824874847127776411443039694389051592145124635490844378130255642752765693890407120283111284316765000645749180288822505352501861257195960128525960418404774436619529817773459198268065709767064598308082608109337158602927125644880036055446842995394476366770872364117175239884406760485305848864493739499504392963295387516098554438251252486287315978444632100288391159069513665622892184147377430660017269064216314044538754986908504965776567592061950572488346266774840439392992871099154439658791611017807192708601473794082677034875991711712839230126426791071352984543648012937947037753575375040046764495862676093683555226439651695465214815214564045671683209573744703248122302073524235222782011551736047484049940566608761314884952385623657426286984431299387264223494331247251695035920997630045288051985796581735253031855095734994702323372767680434320372371358208514386161807824094211406017077057681618563506824462507672499213262962050653636150604636813302357401076353456780306366770399402263353459513732101609057936629596760862766436204974584026785745826067150601651416509653311312257323521470962454567693169469818165574943846754385013710385609445073226065759614555740278029180864101039640157003847772681461933766608520730602890319871123179941870008811420475967031993019721292183133758093949406939652398599519672662411049142220315039805474111098855767170048770783560759174013367296946638271656238787420981851702619053744806332012493178141602213898668388712998512756036771357385206948329239298807516694953814693720048229647293048056331265195037121054022115441868442670280473506498551412297880384312473713380564764159899942048060356745863908010902230964075673990385182437331505988923117412916700150241837983775128046411352228138119876809545584444570443347872856695813698044037133648970190072128464354669077148179236958137004869599834164764747494805309536229934978506910688264436888356383974787838537387187841566823557909442831563769727985839249267304457033791105118767948473474042809317178565809335268316324420040570235176099114072999727457879465811886218940986224633055296998229833996940360896329868864364653862830780554332074293100857235815847819975826812991652016737242925678140172314816371649578265526072666356756752517107018796020915298198762366163369556351250086487862926783601433251979292229580324497550784524234395521051827588464289592550437275513651200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 999: 5142120423742675471974126287955809574535357068046529599000560728039399275930931304341705443290300229914422726794668177537968264648144118498487805119226260378528650131991088676902836811857270541513296947526699705880730381294593006898814262085704336473825201541006210955753704810537413120555128907013106764170210420629126960215958541001171658832595950907229541457834088209412944936905053972218397142776849344658277652614892680821674419697222923130014645284479895717056274392491034125201955158674450551217874664620940928171427683754069233736509184926590369183895070592006924781272099864100239363770546451883318349964152398948931966679860602627409906331644763679137682497780242630009822921710929339761344862731457826420617686381968911400073392366124777065987424836126250033579686085082101266467177145863298853308178221540976580228331239763953108737488691493181833643401836558191778626398618442140468218270066858025640661491000558898610528392279711579575345703200785278416348411772675840280709593777527474095922179716471353719960201704105588347086479022160191444830756096400533705391196695396662879167956803453360810349846148441318082659273788717329596246494808484632922731776348571012795857047452180584628986442772443700080676049673819149856254912408951932826185765196259801406717427502413558108931158666261380067455659044728430258922799402098021392057660641081228877422498521314624574441740894508178111385410004911439667702696237159978509689180822381441616419582068514764153876222307554547594732358511527444499897458759372982433792122654903561638842618444515784825627448071849634297643169362409668516222758076203698145001415117323006038425703965914796426427671784982873817168224589258130683058917988733709001146483964613456875437013984505541825689086094075705760437211402385873368677829365976836468858431398089165749482066656712849497341765168981001121722892025503801609269782750165912686412855279381595779876529427944264414478121201023565907692108302876619530698352008605101070206468704706785269261493986427523865931377207048551250785411318329249855779517786463477651967611696076738366693440412084695489984239864456563532165840963582864286049480561230753012702462130127137450345350359359867882547235683710571018784016493910038168014978153353097170254842715035335189179028979337119830781198392063337314155334478636683363262982739406004002266047843272582071916617807353681712781581451680468476890933136639338084566580809048080468359779806934561186367642359343545836729611491944504786419220499142487390760086756065236043333233346060550395020264308177305185193132970079897858502314955851005175681382393415134546851874491465839660269856799739588390788616285622308116117137884072465953587955513347680498150094614231017861871571733053758969929765508087588060032519546969078084262395141708005237055101766716471322442729268007817300289076611523200827716220759305897838985100568942910630581392931521412710812611627780351475138825434194100790648741408739165327268324724814490022832365413572546951682824848375315512140247418809107217287405055515586541323054413736009057491568285635589733988075995955259789133788061014117612372700229521937709121536568616897024085971931708565098241621955888612739889590429896488315826527248677547766604473044643680531889217189519948956302468329241617445146397986279285610720245607340812533508949433972935867033257871847610121142227746914970178327007585588874258396444641885137938545... [truncated message content] |
From: <th...@us...> - 2009-04-01 00:08:02
|
Revision: 6143 http://jython.svn.sourceforge.net/jython/?rev=6143&view=rev Author: thobes Date: 2009-04-01 00:07:49 +0000 (Wed, 01 Apr 2009) Log Message: ----------- Checking in the ssa compiler, it's almost starting to be able to do stuff now. Modified Paths: -------------- trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/NodeSeaGenerator.java trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/SeaScope.java trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/ValueCarrier.java trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/GraphBuilder.java trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/StateCarrier.java trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SuperGraph.java trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SupergraphVisitor.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayValue.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/CodeGenerationTraverser.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ExceptionValue.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Graph.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphBuilder.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphTraverser.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphVisitor.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/IfNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/InvocationNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/LoadNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Node.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/PhiNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Selection.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SerializationTraverser.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/StoreNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SwitchNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ThrowNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/TransformationTraverser.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Value.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ValueNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/VariableFactory.java trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/GraphvizOutput.java Added Paths: ----------- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphReferenceNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/NodeSuccession.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ReturnNode.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Variable.java trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java Removed Paths: ------------- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/Variable.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Continuation.java trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/OpNode.java Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/NodeSeaGenerator.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/NodeSeaGenerator.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/NodeSeaGenerator.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -70,9 +70,9 @@ import org.python.compiler.sea.SelectionCallback; import org.python.compiler.sea.StateCarrier; import org.python.compiler.sea.UnrollerCallback; -import org.python.compiler.sea.Variable; import org.thobe.compiler.sea.ExceptionValue; import org.thobe.compiler.sea.Value; +import org.thobe.compiler.sea.Variable; /** * Intermediate code generator that generates a Sea of Nodes type of SSA IR. @@ -112,7 +112,7 @@ public Value loadConstant(Constant token) { final Value constant = constants.get(token); if (constant == null) { - throw new IllegalArgumentException("No such constant: " + token); + throw new IllegalArgumentException("No such constant: " + token + " in " + constants); } return constant; } @@ -408,7 +408,7 @@ @Override public Value visitLambda(Lambda node) throws Exception { linenumber(node); - generate.returnValue(evaluate(node.getInternalBody())); + generate.returnPythonValue(evaluate(node.getInternalBody())); return generate.graph(); } @@ -721,7 +721,7 @@ @Override public Value visitReturn(Return node) throws Exception { linenumber(node); - generate.returnValue(evaluate(node.getInternalValue())); + generate.returnPythonValue(evaluate(node.getInternalValue())); return null; } Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/SeaScope.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/SeaScope.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/SeaScope.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -120,9 +120,9 @@ }; } - public static SeaScope forFunction(String name, String[] parameters, - String[] locals, String[] globals, final String[] free, - String[] cell, boolean hasStarImport) { + public static SeaScope forFunction(String name, final String[] parameters, + final String[] locals, final String[] globals, final String[] free, + final String[] cell, boolean hasStarImport) { return new SeaScope() { @Override public GraphBuilder builder(SuperGraph ocean, CompilerFlags flags) { @@ -137,8 +137,13 @@ } public void populate(VariableFactory factory) { - // TODO Auto-generated method stub - + for (String var : parameters) { + factory.createParameter(var); + } + for (String var : locals) { + factory.createLocalVariable(var); + } + // TODO: more stuff } @Override @@ -233,7 +238,7 @@ } @Override - public void returnValue(Value value) { + public void returnPythonValue(Value value) { scope.returnValue(this, value); } Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/ValueCarrier.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/ValueCarrier.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/advanced/sea/ValueCarrier.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,7 +1,7 @@ package org.python.compiler.advanced.sea; import org.thobe.compiler.sea.Value; -import org.python.compiler.sea.Variable; +import org.thobe.compiler.sea.Variable; abstract class ValueCarrier { private final Variable[] closure; Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/GraphBuilder.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/GraphBuilder.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/GraphBuilder.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -6,12 +6,13 @@ import org.python.core.CodeFlag; import org.python.core.CompilerFlags; import org.thobe.compiler.sea.ArrayValue; -import org.thobe.compiler.sea.Continuation; +import org.thobe.compiler.sea.NodeSuccession; import org.thobe.compiler.sea.ExceptionValue; import org.thobe.compiler.sea.NamespacePopulator; import org.thobe.compiler.sea.InvocationType; import org.thobe.compiler.sea.Selection; import org.thobe.compiler.sea.Value; +import org.thobe.compiler.sea.Variable; public abstract class GraphBuilder extends org.thobe.compiler.sea.GraphBuilder { private final CallStrategy call; @@ -79,8 +80,7 @@ * @param line the line number to set. */ public final void linenumber(int line) { - // TODO Auto-generated method stub - + // FIXME: implement this somehow } // --- Handle --- @@ -125,7 +125,7 @@ * @return a Python string with the supplied content. */ public Value string(String string) { - // TODO Auto-generated method stub + // TODO: implement this return null; } @@ -155,36 +155,36 @@ // phi verify that each value comes from different paths? // Does it have to? Selection select = something();// TODO: design API like: selection(types.isTrue(), result); - replaceContinuation(select.onTrue()); + replaceSuccession(select.onTrue()); Value on_true = schedule(selection.onTrue()); // schedule artificial node - Continuation after_true = replaceContinuation(select.onFalse()); + NodeSuccession after_true = replaceSuccession(select.onFalse()); Value on_false = schedule(selection.onFalse()); // schedule artificial node - Continuation after_false = currentContinuation(); - replaceContinuation(merge(after_true, after_false)); - return super.phiOrNull(on_true, on_false); + NodeSuccession after_false = currentSuccession(); + replaceSuccession(merge(after_true, after_false)); + return phiOrNull(on_true, on_false); } public void loop(LoopCallback loop) throws Exception { // TODO: this has issues for the same reasons as selection does. - final Continuation start = currentContinuation(); - final Continuation after = newContinuation(); + final NodeSuccession start = currentSuccession(); + final NodeSuccession after = newSuccession(); StateCarrier state = loop.head(); - replaceContinuation(state.onTrue()); + replaceSuccession(state.onTrue()); loop.body(state.payload(), new LoopHandle() { @Override public void breakLoop() { - nextContinuation(after); + nextSuccession(after); } @Override public void continueLoop() { - nextContinuation(start); + nextSuccession(start); } }); - replaceContinuation(state.onFalse()); + replaceSuccession(state.onFalse()); loop.orelse(); - nextContinuation(after); - replaceContinuation(after); + nextSuccession(after); + replaceSuccession(after); } public void tryBlock(BlockCallback block) { @@ -724,7 +724,7 @@ // --- Exit --- - public abstract void returnValue(Value evaluate); + public abstract void returnPythonValue(Value evaluate); public abstract Value yeildValue(Value value); Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/StateCarrier.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/StateCarrier.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/StateCarrier.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,6 +1,6 @@ package org.python.compiler.sea; -import org.thobe.compiler.sea.Continuation; +import org.thobe.compiler.sea.NodeSuccession; import org.thobe.compiler.sea.Value; public class StateCarrier { @@ -15,12 +15,12 @@ return payload; } - Continuation onTrue() { + NodeSuccession onTrue() { // TODO Auto-generated method stub return null; } - Continuation onFalse() { + NodeSuccession onFalse() { // TODO Auto-generated method stub return null; } Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SuperGraph.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SuperGraph.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SuperGraph.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -7,8 +7,8 @@ import org.thobe.compiler.sea.VariableFactory; public class SuperGraph { - private final Graph constants = null; - private final Graph module = null; + private Graph constants; + private Graph module; public GraphBuilder constants() { // TODO: capture this graph... @@ -28,7 +28,7 @@ } @Override - public void returnValue(Value evaluate) { + public void returnPythonValue(Value evaluate) { throw new UnsupportedOperationException(); } @@ -40,7 +40,8 @@ } public void accept(NodeSorter sort, SupergraphVisitor visitor) { - // TODO Auto-generated method stub - + // TODO: replace this method + constants.serialize(visitor.visitGraph()); + module.serialize(visitor.visitGraph()); } } Modified: trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SupergraphVisitor.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SupergraphVisitor.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/SupergraphVisitor.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +1,7 @@ package org.python.compiler.sea; +import org.thobe.compiler.sea.GraphVisitor; + public interface SupergraphVisitor { - + GraphVisitor visitGraph(); } Deleted: trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/Variable.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/Variable.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/Variable.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +0,0 @@ -package org.python.compiler.sea; - -public class Variable { - -} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,8 +1,26 @@ package org.thobe.compiler.sea; -public class ArrayNode extends ValueNode { +import java.util.Arrays; + +class ArrayNode extends ValueNode { + private final Value[] content; + ArrayNode(Value[] content) { - // TODO Auto-generated constructor stub + this.content = content; } + @Override + public Value result() { + throw new UnsupportedOperationException("Not implemented"); + } + + @Override + ArrayNode accept(GraphTraverser traverser) { + return traverser.array(this, content); + } + + @Override + public String toString() { + return "Array:[" + Arrays.toString(content) + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayValue.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayValue.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ArrayValue.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,7 +1,12 @@ package org.thobe.compiler.sea; public class ArrayValue extends Value { + private final ArrayNode from; + ArrayValue(ArrayNode from) { + this.from = from; + } + public Value[] array(int size) { // TODO Auto-generated method stub return null; @@ -11,4 +16,9 @@ // TODO Auto-generated method stub return null; } + + @Override + public String toString() { + return "value_of(" + from + ")"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/CodeGenerationTraverser.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/CodeGenerationTraverser.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/CodeGenerationTraverser.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,6 +1,6 @@ package org.thobe.compiler.sea; -class CodeGenerationTraverser extends GraphTraverser { +abstract class CodeGenerationTraverser extends GraphTraverser { public CodeGenerationTraverser(GraphVisitor visitor) { } Deleted: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Continuation.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Continuation.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Continuation.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +0,0 @@ -package org.thobe.compiler.sea; - -public class Continuation { - -} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ExceptionValue.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ExceptionValue.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ExceptionValue.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +1,13 @@ package org.thobe.compiler.sea; public class ExceptionValue extends Value { + ExceptionValue() { + throw new UnsupportedOperationException( + "How should exceptions be created?"); + } + @Override + public String toString() { + return "ExceptionValue[how did you get this?]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Graph.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Graph.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Graph.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,18 +1,92 @@ package org.thobe.compiler.sea; public final class Graph { - private Node entry; + private final Node entry; - public void compile(GraphVisitor visitor) { - entry.accept(new CodeGenerationTraverser(visitor)); + Graph(Node entry) { + this.entry = entry; } - public void transform(GraphVisitor visitor) { - entry.accept(new TransformationTraverser(visitor)); + public void serialize(final GraphVisitor visitor) { + entry.accept(new GraphTraverser() { + @Override + ArrayNode array(ArrayNode original, Value[] content) { + visitor.node(original); + return original; + } + + @Override + InvocationNode invoke(InvocationNode original, + InvocationType invocation, Value[] arguments) { + visitor.node(original); + return original; + } + + @Override + LoadNode load(LoadNode original, Variable variable) { + visitor.node(original); + return original; + } + + @Override + PhiNode phi(PhiNode original, Node[] array) { + visitor.node(original); + return original; + } + + @Override + ThrowNode raiseException(ThrowNode original, + ExceptionValue exception) { + visitor.node(original); + return original; + } + + @Override + ReturnNode returnValue(ReturnNode original, Value value) { + visitor.node(original); + return original; + } + + @Override + SelectTraverser select(final SwitchNode original, Value select) { + visitor.node(original); + return new SelectTraverser() { + @Override + void onCase(Integer key, Node node) { + // TODO Auto-generated method stub + + } + + @Override + void otherwise(Node node) { + // TODO Auto-generated method stub + + } + + @Override + SwitchNode done() { + return original; + } + }; + } + + @Override + IfNode selection(IfNode original, Value predicate, + Node trueSuccessor, Node falseSuccessor) { + visitor.node(original); + return original; + } + + @Override + StoreNode store(StoreNode original, Variable variable, Value value) { + visitor.node(original); + return original; + } + }); } public byte[] serialize() { - SerializationTraverser traverser = new SerializationTraverser(); + SerializationTraverser traverser = null;//new SerializationTraverser(); entry.accept(traverser); return traverser.serialization(); } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphBuilder.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphBuilder.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphBuilder.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,54 +1,71 @@ package org.thobe.compiler.sea; -import org.python.compiler.sea.Variable; +public abstract class GraphBuilder { + private final GraphReferenceNode entry; + private NodeSuccession succession; -public abstract class GraphBuilder { protected GraphBuilder(NamespacePopulator populator) { - populator.populate(new VariableFactory(){}); + populator.populate(new VariableFactory() { + }); + entry = new GraphReferenceNode(); + succession = entry.succession(); } - protected InvocationNode invoke(InvocationType invocation, + public final Graph build() { + return new Graph(entry); + } + + protected ValueNode invoke(InvocationType invocation, Value... arguments) { return new InvocationNode(invocation, arguments); } - protected ArrayNode array(Value[] content) { + protected ValueNode array(Value[] content) { return new ArrayNode(content); } protected <N extends Node> N schedule(N node) { - // TODO Auto-generated method stub + succession = succession.setNext(node); return node; } protected <V extends Value> V schedule(V value) { - // TODO Auto-generated method stub + schedule(ValueNode.repeat(value)); return value; } - protected Continuation replaceContinuation(Continuation progression) { - // TODO Auto-generated method stub - return null; + protected NodeSuccession replaceSuccession(NodeSuccession succession) { + try { + return this.succession; + } finally { + this.succession = succession; + } } - protected Continuation currentContinuation() { - // TODO Auto-generated method stub - return null; + protected NodeSuccession currentSuccession() { + return succession; } - protected void nextContinuation(Continuation start) { + protected void nextSuccession(NodeSuccession start) { // TODO Auto-generated method stub } - protected Continuation newContinuation() { + protected NodeSuccession newSuccession() { // TODO Auto-generated method stub return null; } - protected Continuation merge(Continuation... progressions) { - // TODO Auto-generated method stub - return null; + protected NodeSuccession merge(final NodeSuccession... previous) { + return new NodeSuccession(){ + @Override + NodeSuccession setNext(Node node) { + for (NodeSuccession prev : previous) { + prev.setNext(node); + } + return node.succession(); + } + }; } protected Value phi(Value... values) { @@ -79,6 +96,10 @@ } } + protected final Node returnValue(Value value) { + return new ReturnNode(value); + } + protected final ValueNode loadVariable(Variable variable) { return new LoadNode(variable); } Added: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphReferenceNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphReferenceNode.java (rev 0) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphReferenceNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -0,0 +1,26 @@ +package org.thobe.compiler.sea; + +class GraphReferenceNode extends Node { + Node start; + + @Override + Node accept(GraphTraverser traverser) { + return start.accept(traverser); + } + + @Override + NodeSuccession succession() { + return new NodeSuccession() { + @Override + NodeSuccession setNext(Node node) { + start = node; + return node.succession(); + } + }; + } + + @Override + public String toString() { + return start != null ? start.toString() : "NullGraph"; + } +} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphTraverser.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphTraverser.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphTraverser.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +1,32 @@ package org.thobe.compiler.sea; -class GraphTraverser { +abstract class GraphTraverser { + abstract class SelectTraverser { + abstract void onCase(Integer key, Node node); + abstract void otherwise(Node node); + + abstract SwitchNode done(); + } + + abstract SelectTraverser select(SwitchNode original, Value select); + + abstract IfNode selection(IfNode original, Value predicate, + Node trueSuccessor, Node falseSuccessor); + + abstract ReturnNode returnValue(ReturnNode original, Value value); + + abstract StoreNode store(StoreNode original, Variable variable, Value value); + + abstract ThrowNode raiseException(ThrowNode original, + ExceptionValue exception); + + abstract InvocationNode invoke(InvocationNode original, + InvocationType invocation, Value[] arguments); + + abstract LoadNode load(LoadNode original, Variable variable); + + abstract PhiNode phi(PhiNode original, Node[] array); + + abstract ArrayNode array(ArrayNode original, Value[] content); } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphVisitor.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphVisitor.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/GraphVisitor.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,20 +1,21 @@ package org.thobe.compiler.sea; public interface GraphVisitor { + void node(Node node); /** * Allocate a location to store a local variable. * * @param name The name of the local variable. * @return a new location for storing the local variable. */ - VariableLocation allocateLocal(String name, ValueType type); + //VariableLocation allocateLocal(String name, ValueType type); /** * Allocate a location to store a temporary variable. * * @return a new location for storing the temporary variable. */ - VariableLocation allocateTemporary(); + //VariableLocation allocateTemporary(); - void deallocate(VariableLocation location); + //void deallocate(VariableLocation location); } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/IfNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/IfNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/IfNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -3,13 +3,34 @@ class IfNode extends Node { private Node trueSuccessor; private Node falseSuccessor; + private final Value predicate; IfNode(Value predicate) { + this.predicate = predicate; } void setOnTrue(Node next) { + trueSuccessor = next; } void setOnFalse(Node next) { + falseSuccessor = next; } + + @Override + IfNode accept(GraphTraverser traverser) { + return traverser.selection(this, predicate, trueSuccessor, + falseSuccessor); + } + + @Override + NodeSuccession succession() { + return NodeSuccession.DUMMY; + } + + @Override + public String toString() { + return "IfNode[" + predicate + " ? " + trueSuccessor + " : " + + falseSuccessor + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/InvocationNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/InvocationNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/InvocationNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,9 +1,40 @@ package org.thobe.compiler.sea; -public class InvocationNode extends ValueNode { +class InvocationNode extends ValueNode { + private final InvocationType invocation; + private final Value[] arguments; + private final Value result = new Value() { + @Override + public String toString() { + return "value_of(" + InvocationNode.this + ")"; + } + }; InvocationNode(InvocationType invocation, Value[] arguments) { - // TODO Auto-generated constructor stub + this.invocation = invocation; + this.arguments = arguments; } + @Override + public Value result() { + return result; + } + + @Override + InvocationNode accept(GraphTraverser traverser) { + return traverser.invoke(this, invocation, arguments); + } + + @Override + public String toString() { + StringBuilder args = new StringBuilder(invocation.toString()); + String sep = "("; + for (Value arg : arguments) { + args.append(sep); + args.append(arg.toString()); + sep = ", "; + } + args.append(")"); + return "InvocationNode[" + args + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/LoadNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/LoadNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/LoadNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,11 +1,32 @@ package org.thobe.compiler.sea; -import org.python.compiler.sea.Variable; +class LoadNode extends ValueNode { + private final Variable variable; -public class LoadNode extends ValueNode { LoadNode(Variable variable) { - // TODO Auto-generated constructor stub + this.variable = variable; } private StoreNode defined; + private final Value result = new Value() { + @Override + public String toString() { + return "value_of(" + LoadNode.this + ")"; + } + }; + + @Override + public Value result() { + return result; + } + + @Override + LoadNode accept(GraphTraverser traverser) { + return traverser.load(this, variable); + } + + @Override + public String toString() { + return "LoadNode[" + variable + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Node.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Node.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Node.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,10 +1,8 @@ package org.thobe.compiler.sea; public abstract class Node { - - public void accept(GraphTraverser serializationTraverser) { - // TODO Auto-generated method stub - - } - + abstract Node accept(GraphTraverser traverser); + abstract NodeSuccession succession(); + @Override + abstract public String toString(); } Copied: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/NodeSuccession.java (from rev 6138, trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Continuation.java) =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/NodeSuccession.java (rev 0) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/NodeSuccession.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -0,0 +1,19 @@ +package org.thobe.compiler.sea; + +public abstract class NodeSuccession { + public static final NodeSuccession DUMMY = new NodeSuccession() { + @Override + NodeSuccession setNext(Node node) { + throw new IllegalStateException( + "Trying to set next node for node with no single succession."); + } + }; + public static final NodeSuccession NOTHING = new NodeSuccession() { + @Override + NodeSuccession setNext(Node node) { + return this; + } + }; + + abstract NodeSuccession setNext(Node node); +} Deleted: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/OpNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/OpNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/OpNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,5 +0,0 @@ -package org.thobe.compiler.sea; - -class OpNode extends Node { - Value[] parameters; -} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/PhiNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/PhiNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/PhiNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -6,7 +6,39 @@ PhiNode(Value[] values) { // TODO Auto-generated constructor stub } + private List<Node> components; private final Value result = new Value() { + @Override + public String toString() { + return "phi(" + parts() + ")"; + } }; + + @Override + public Value result() { + return result; + } + + @Override + PhiNode accept(GraphTraverser traverser) { + return traverser.phi(this, + components.toArray(new Node[components.size()])); + } + + private StringBuilder parts() { + StringBuilder parts = new StringBuilder(); + String sep = ""; + for (Node part : components) { + parts.append(sep); + parts.append(part); + sep = ", "; + } + return parts; + } + + @Override + public String toString() { + return "PhiNode[" + parts() + "]"; + } } Added: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ReturnNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ReturnNode.java (rev 0) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ReturnNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -0,0 +1,24 @@ +package org.thobe.compiler.sea; + +class ReturnNode extends Node { + private final Value value; + + ReturnNode(Value value) { + this.value = value; + } + + @Override + ReturnNode accept(GraphTraverser traverser) { + return traverser.returnValue(this, value); + } + + @Override + NodeSuccession succession() { + return NodeSuccession.NOTHING; + } + + @Override + public String toString() { + return "ReturnNode[" + value + "]"; + } +} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Selection.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Selection.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Selection.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -2,12 +2,12 @@ public class Selection { - public Continuation onTrue() { + public NodeSuccession onTrue() { // TODO Auto-generated method stub return null; } - public Continuation onFalse() { + public NodeSuccession onFalse() { // TODO Auto-generated method stub return null; } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SerializationTraverser.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SerializationTraverser.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SerializationTraverser.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,6 +1,6 @@ package org.thobe.compiler.sea; -class SerializationTraverser extends GraphTraverser { +abstract class SerializationTraverser extends GraphTraverser { public SerializationTraverser() { throw new UnsupportedOperationException( "Graph serialization is not implemented."); Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/StoreNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/StoreNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/StoreNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,10 +1,33 @@ package org.thobe.compiler.sea; -import org.python.compiler.sea.Variable; +class StoreNode extends Node { + private Node next; + private final Variable variable; + private final Value value; -public class StoreNode extends OpNode { - StoreNode(Variable variable, Value value) { - // TODO Auto-generated constructor stub + this.variable = variable; + this.value = value; } + + @Override + StoreNode accept(GraphTraverser traverser) { + return traverser.store(this, variable, value); + } + + @Override + NodeSuccession succession() { + return new NodeSuccession() { + @Override + NodeSuccession setNext(Node node) { + next = node; + return node.succession(); + } + }; + } + + @Override + public String toString() { + return "StoreNode[" + variable + " <- " + value + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SwitchNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SwitchNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/SwitchNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,13 +1,50 @@ package org.thobe.compiler.sea; import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; class SwitchNode extends Node { private Node defaultSuccessor; - private Map<Integer, Node> successors; + private final SortedMap<Integer, Node> successors = new TreeMap<Integer, Node>(); + private final Value select; + SwitchNode(Value select) { + this.select = select; } + void addSuccessor(int on, Node next) { successors.put(on, next); } + + @Override + SwitchNode accept(GraphTraverser traverser) { + GraphTraverser.SelectTraverser selector = traverser.select(this, select); + for (Map.Entry<Integer, Node> entry : successors.entrySet()) { + selector.onCase(entry.getKey(), entry.getValue()); + } + if (defaultSuccessor != null) { + selector.otherwise(defaultSuccessor); + } + return selector.done(); + } + + @Override + NodeSuccession succession() { + return NodeSuccession.DUMMY; + } + + @Override + public String toString() { + StringBuilder targets = new StringBuilder(); + String sep = ": "; + for (Map.Entry<Integer, Node> entry : successors.entrySet()) { + targets.append(sep); + targets.append(entry.getKey().toString()); + targets.append(" -> "); + targets.append(entry.getValue().toString()); + sep = ", "; + } + return "SwitchNode[" + targets + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ThrowNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ThrowNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ThrowNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,9 +1,24 @@ package org.thobe.compiler.sea; -public class ThrowNode extends Node { +class ThrowNode extends Node { + private final ExceptionValue exception; ThrowNode(ExceptionValue exception) { - // TODO Auto-generated constructor stub + this.exception = exception; } + @Override + ThrowNode accept(GraphTraverser traverser) { + return traverser.raiseException(this, exception); + } + + @Override + NodeSuccession succession() { + return NodeSuccession.DUMMY; + } + + @Override + public String toString() { + return "ThrowNode[" + exception + "]"; + } } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/TransformationTraverser.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/TransformationTraverser.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/TransformationTraverser.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,6 +1,6 @@ package org.thobe.compiler.sea; -class TransformationTraverser extends GraphTraverser { +abstract class TransformationTraverser extends GraphTraverser { public TransformationTraverser(GraphVisitor visitor) { // TODO Auto-generated constructor stub Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Value.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Value.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Value.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,7 +1,9 @@ package org.thobe.compiler.sea; +public abstract class Value { + Value() { + } -public class Value { public static Value integer(int integer) { // TODO Auto-generated method stub return null; @@ -12,4 +14,6 @@ return null; } + @Override + public abstract String toString(); } Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ValueNode.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ValueNode.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/ValueNode.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -1,12 +1,44 @@ package org.thobe.compiler.sea; -public class ValueNode extends OpNode { +public abstract class ValueNode extends Node { + static ValueNode repeat(final Value value) { + return new ValueNode() { + @Override + public Value result() { + return value; + } + + @Override + ValueNode accept(GraphTraverser traverser) { + throw new UnsupportedOperationException("Needs fixing!"); + } + + @Override + public String toString() { + return "RepeatedValueNode[" + value + "]"; + } + }; + } + + private Node next; + ValueNode() { // TODO Auto-generated constructor stub } - public Value result() { - // TODO Auto-generated method stub - return null; + public abstract Value result(); + + @Override + abstract ValueNode accept(GraphTraverser traverser); + + @Override + NodeSuccession succession() { + return new NodeSuccession() { + @Override + NodeSuccession setNext(Node node) { + next = node; + return node.succession(); + } + }; } } Copied: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Variable.java (from rev 6138, trunk/sandbox/tobias/compiler/src/org/python/compiler/sea/Variable.java) =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Variable.java (rev 0) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/Variable.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -0,0 +1,5 @@ +package org.thobe.compiler.sea; + +public class Variable { + +} Modified: trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/VariableFactory.java =================================================================== --- trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/VariableFactory.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/src/org/thobe/compiler/sea/VariableFactory.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -12,4 +12,9 @@ } + public void createParameter(String param) { + // TODO Auto-generated method stub + + } + } Added: trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java =================================================================== --- trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java (rev 0) +++ trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/BuildGraph.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -0,0 +1,34 @@ +package org.python.compiler.sea.output; + +import org.python.compiler.sea.PythonOperation; +import org.thobe.compiler.sea.GraphBuilder; +import org.thobe.compiler.sea.GraphVisitor; +import org.thobe.compiler.sea.NamespacePopulator; +import org.thobe.compiler.sea.Node; +import org.thobe.compiler.sea.ValueNode; +import org.thobe.compiler.sea.VariableFactory; + +public final class BuildGraph extends GraphBuilder { + protected BuildGraph(NamespacePopulator populator) { + super(populator); + } + + public static void main(String[] args) { + BuildGraph builder = new BuildGraph(new NamespacePopulator() { + public void populate(VariableFactory factory) { + factory.createLocalVariable("x"); + factory.createLocalVariable("y"); + } + }); + ValueNode load_x = builder.loadVariable(builder.variable("x")); + ValueNode load_y = builder.loadVariable(builder.variable("y")); + ValueNode add = builder.schedule(builder.invoke( + PythonOperation.BINARY_ADD, load_x.result(), load_y.result())); + builder.schedule(builder.returnValue(add.result())); + builder.build().serialize(new GraphVisitor() { + public void node(Node node) { + System.out.println(node); + } + }); + } +} Modified: trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/GraphvizOutput.java =================================================================== --- trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/GraphvizOutput.java 2009-03-31 23:53:50 UTC (rev 6142) +++ trunk/sandbox/tobias/compiler/test/org/python/compiler/sea/output/GraphvizOutput.java 2009-04-01 00:07:49 UTC (rev 6143) @@ -8,16 +8,30 @@ import org.python.core.CompileMode; import org.python.core.CompilerFlags; import org.python.core.ParserFacade; +import org.thobe.compiler.sea.GraphVisitor; +import org.thobe.compiler.sea.Node; public class GraphvizOutput { public static void print(CompileMode mode, String source) throws Exception { CompilerFlags flags = new CompilerFlags(); mod ast = ParserFacade.parse(source, mode, GraphvizOutput.class.getName(), flags); + print(ast, flags); + } + + private static void print(mod ast, CompilerFlags flags) throws Exception { NodeSeaBundle bundle = new NodeSeaBundle(); CompilerDirector.compile(bundle, new Preferences(), flags, true, false, ast); bundle.accept(new SupergraphVisitor() { + public GraphVisitor visitGraph() { + System.out.println("graph:"); + return new GraphVisitor() { + public void node(Node node) { + System.out.println(" " + node); + } + }; + } }); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |