Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv11196 Modified Files: AutoInternalTables.java BytecodeLoader.java CachedJarsPackageManager.java InternalTables.java MakeProxies.java PackageManager.java PathPackageManager.java Py.java PyBeanEventProperty.java PyClass.java PyComplex.java PyFile.java PyFloat.java PyFunction.java PyInstance.java PyInteger.java PyJavaClass.java PyJavaInstance.java PyJavaPackage.java PyList.java PyLong.java PyMethod.java PyModule.java PyObject.java PyReflectedConstructor.java PyReflectedFunction.java PySequence.java PyString.java PyStringMap.java PySystemState.java PyTableCode.java ReflectedArgs.java SysPackageManager.java SyspathJavaLoader.java ThreadStateMapping.java __builtin__.java codecs.java imp.java parser.java Log Message: Consistent formatting. Keep lines shorter than 78 chars. Index: AutoInternalTables.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/AutoInternalTables.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** AutoInternalTables.java 2001/02/01 16:41:10 2.4 --- AutoInternalTables.java 2001/02/02 09:28:36 2.5 *************** *** 10,14 **** protected ReferenceQueue queue = new ReferenceQueue(); ! protected abstract Reference newAutoRef(short type,Object key, Object obj); protected abstract short getAutoRefType(Reference ref); protected abstract Object getAutoRefKey(Reference ref); --- 10,15 ---- protected ReferenceQueue queue = new ReferenceQueue(); ! protected abstract Reference newAutoRef(short type, Object key, ! Object obj); protected abstract short getAutoRefType(Reference ref); protected abstract Object getAutoRefKey(Reference ref); *************** *** 133,137 **** case ADAPTER_CLASS: Map.Entry entry = (Map.Entry)cur; ! if (((Reference)entry.getValue()).get() == null ) continue; return entry.getKey(); } --- 134,139 ---- case ADAPTER_CLASS: Map.Entry entry = (Map.Entry)cur; ! if (((Reference)entry.getValue()).get() == null ) ! continue; return entry.getKey(); } Index: BytecodeLoader.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/BytecodeLoader.java,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** BytecodeLoader.java 2001/02/01 16:41:10 2.11 --- BytecodeLoader.java 2001/02/02 09:28:36 2.12 *************** *** 48,52 **** if (version.compareTo("1.2") >= 0) { try { ! loaderClass = Class.forName("org.python.core.BytecodeLoader2"); } catch (Throwable e) { loaderClass = BytecodeLoader1.class; --- 48,53 ---- if (version.compareTo("1.2") >= 0) { try { ! loaderClass = ! Class.forName("org.python.core.BytecodeLoader2"); } catch (Throwable e) { loaderClass = BytecodeLoader1.class; *************** *** 63,67 **** } ! public static Class makeClass(String name, Vector referents, byte[] data) { Loader loader = makeLoader(); --- 64,70 ---- } ! public static Class makeClass(String name, Vector referents, ! byte[] data) ! { Loader loader = makeLoader(); *************** *** 69,73 **** for (int i = 0; i < referents.size(); i++) { try { ! ClassLoader cur = ((Class)referents.elementAt(i)).getClassLoader(); if (cur != null) loader.addParent(cur); --- 72,77 ---- for (int i = 0; i < referents.size(); i++) { try { ! Class cls = (Class)referents.elementAt(i); ! ClassLoader cur = cls.getClassLoader(); if (cur != null) loader.addParent(cur); Index: CachedJarsPackageManager.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/CachedJarsPackageManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** CachedJarsPackageManager.java 2001/02/01 16:41:10 1.5 --- CachedJarsPackageManager.java 2001/02/02 09:28:36 1.6 *************** *** 43,49 **** /** Filter class/pkg by name helper method - hook. ! * The default impl. is used by {@link #addJarToPackages} in order to filter out classes ! * whose name contains '$' (e.g. inner classes,...). ! * Should be used or overriden by derived classes too. Also to be used in {@link #doDir}. * @param name class/pkg name * @param pkg if true, name refers to a pkg --- 43,50 ---- /** Filter class/pkg by name helper method - hook. ! * The default impl. is used by {@link #addJarToPackages} in order ! * to filter out classes whose name contains '$' (e.g. inner classes,...). ! * Should be used or overriden by derived classes too. ! * Also to be used in {@link #doDir}. * @param name class/pkg name * @param pkg if true, name refers to a pkg *************** *** 55,60 **** /** Filter class by access perms helper method - hook. ! * The default impl. is used by {@link #addJarToPackages} in order to filter out non-public classes. ! * Should be used or overriden by derived classes too. Also to be used in {@link #doDir}. * Access perms can be read with {@link #checkAccess}. * @param name class name --- 56,63 ---- /** Filter class by access perms helper method - hook. ! * The default impl. is used by {@link #addJarToPackages} in order ! * to filter out non-public classes. ! * Should be used or overriden by derived classes too. ! * Also to be used in {@link #doDir}. * Access perms can be read with {@link #checkAccess}. * @param name class name *************** *** 81,85 **** // Add a single class from zipFile to zipPackages // Only add valid, public classes ! private void addZipEntry(Hashtable zipPackages, ZipEntry entry,ZipInputStream zip) throws IOException { String name = entry.getName(); --- 84,90 ---- // Add a single class from zipFile to zipPackages // Only add valid, public classes ! private void addZipEntry(Hashtable zipPackages, ! ZipEntry entry, ! ZipInputStream zip) throws IOException { String name = entry.getName(); *************** *** 143,147 **** * Eventually just using previously cached info. * Eventually updated info is not cached. ! * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(java.net.URL jarurl) { --- 148,153 ---- * Eventually just using previously cached info. * Eventually updated info is not cached. ! * Persistent cache storage access goes through ! * {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(java.net.URL jarurl) { *************** *** 152,156 **** * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. ! * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(URL jarurl,boolean cache) { --- 158,163 ---- * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. ! * Persistent cache storage access goes through ! * {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(URL jarurl,boolean cache) { *************** *** 161,165 **** * Eventually just using previously cached info. * Eventually updated info is not cached. ! * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile) { --- 168,173 ---- * Eventually just using previously cached info. * Eventually updated info is not cached. ! * Persistent cache storage access goes through ! * {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile) { *************** *** 170,174 **** * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. ! * Persistent cache storage access goes through {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile,boolean cache) { --- 178,183 ---- * Eventually just using previously cached info. * Eventually updated info is (re-)cached if param cache is true. ! * Persistent cache storage access goes through ! * {@link #inOpenCacheFile}, {@link #outCreateCacheFile}. */ public void addJarToPackages(File jarfile,boolean cache) { *************** *** 187,195 **** // This is necessary because 'file:' url-connections // return always 0 through getLastModified (bug?). ! // And in order to handle localfiles (from urls too) uniformly. if(jarconn.getURL().getProtocol().equals("file")) { // ??pending: need to use java2 URLDecoder.decode? // but under 1.1 this is absent and should be simulated. ! jarfile = new File(jarurl.getFile().replace('/',File.separatorChar)); } else localfile = false; --- 196,207 ---- // This is necessary because 'file:' url-connections // return always 0 through getLastModified (bug?). ! // And in order to handle localfiles (from urls too) ! // uniformly. if(jarconn.getURL().getProtocol().equals("file")) { // ??pending: need to use java2 URLDecoder.decode? // but under 1.1 this is absent and should be simulated. ! String jarfilename = jarurl.getFile(); ! jarfilename = jarfilename.replace('/',File.separatorChar); ! jarfile = new File(jarfilename); } else localfile = false; *************** *** 258,267 **** InputStream jarin; ! if (jarconn == null) jarin = new BufferedInputStream(new FileInputStream(jarfile)); ! else jarin = jarconn.getInputStream(); zipPackages = getZipPackages(jarin); ! if(caching) writeCacheFile(entry, jarcanon, zipPackages, brandNew); // Write the cache file } --- 270,283 ---- InputStream jarin; ! if (jarconn == null) ! jarin = new BufferedInputStream( ! new FileInputStream(jarfile)); ! else ! jarin = jarconn.getInputStream(); zipPackages = getZipPackages(jarin); ! if (caching) ! writeCacheFile(entry, jarcanon, zipPackages, brandNew); } *************** *** 270,274 **** // silently skip any bad directories warning("skipping bad jar, '" + ! (jarfile!=null?jarfile.toString():jarurl.toString()) + "'"); // ?? solve bug } --- 286,293 ---- // silently skip any bad directories warning("skipping bad jar, '" + ! (jarfile != null ? ! jarfile.toString() : ! jarurl.toString()) + ! "'"); } *************** *** 425,429 **** /** Open cache index for reading from persistent storage - hook. * Must Return null if this is absent. ! * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ --- 444,449 ---- /** Open cache index for reading from persistent storage - hook. * Must Return null if this is absent. ! * This default impl is part of the off-the-shelf local ! * file-system cache impl. * Can be overriden. */ *************** *** 440,444 **** /** Open cache index for writing back to persistent storage - hook. ! * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ --- 460,465 ---- /** Open cache index for writing back to persistent storage - hook. ! * This default impl is part of the off-the-shelf local ! * file-system cache impl. * Can be overriden. */ *************** *** 451,463 **** /** Open cache file for reading from persistent storage - hook. ! * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ ! protected DataInputStream inOpenCacheFile(String cachefile) throws IOException { ! return new DataInputStream(new BufferedInputStream(new FileInputStream(cachefile))); } /** Delete (invalidated) cache file from persistent storage - hook. ! * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ --- 472,490 ---- /** Open cache file for reading from persistent storage - hook. ! * This default impl is part of the off-the-shelf local ! * file-system cache impl. * Can be overriden. */ ! protected DataInputStream inOpenCacheFile(String cachefile) ! throws IOException ! { ! return new DataInputStream( ! new BufferedInputStream( ! new FileInputStream(cachefile))); } /** Delete (invalidated) cache file from persistent storage - hook. ! * This default impl is part of the off-the-shelf local ! * file-system cache impl. * Can be overriden. */ *************** *** 466,479 **** } ! /** Create/open cache file for rewriting back to persistent storage - hook. * If create is false, cache file is supposed to exist and must be opened * for rewriting, entry.cachefile is a valid cachefile id. ! * If create is true, cache file must be created. entry.cachefile is a flat ! * jarname to be used to produce a valid cachefile id (to be put back in entry.cachefile ! * on exit). ! * This default impl is part of the off-the-shelf local file-system cache impl. * Can be overriden. */ ! protected DataOutputStream outCreateCacheFile(JarXEntry entry, boolean create) throws IOException { File cachefile = null; --- 493,511 ---- } ! /** ! * Create/open cache file for rewriting back to persistent storage - hook. * If create is false, cache file is supposed to exist and must be opened * for rewriting, entry.cachefile is a valid cachefile id. ! * If create is true, cache file must be created. entry.cachefile is a ! * flat jarname to be used to produce a valid cachefile id (to be put ! * back in entry.cachefile on exit). ! * This default impl is part of the off-the-shelf local file-system ! * cache impl. * Can be overriden. */ ! protected DataOutputStream outCreateCacheFile(JarXEntry entry, ! boolean create) ! throws IOException ! { File cachefile = null; *************** *** 492,496 **** } else cachefile = new File(entry.cachefile); ! return new DataOutputStream(new BufferedOutputStream(new FileOutputStream(cachefile))); } --- 524,530 ---- } else cachefile = new File(entry.cachefile); ! return new DataOutputStream( ! new BufferedOutputStream( ! new FileOutputStream(cachefile))); } Index: InternalTables.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/InternalTables.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** InternalTables.java 2001/02/01 16:41:10 2.6 --- InternalTables.java 2001/02/02 09:28:36 2.7 *************** *** 3,6 **** --- 3,8 ---- package org.python.core; + import java.util.StringTokenizer; + public abstract class InternalTables { *************** *** 32,36 **** } } ! // System.err.println("*InternalTables*-create-try: "+id); // ??dbg return (InternalTables)Class.forName(id).newInstance(); } --- 34,38 ---- } } ! // System.err.println("*InternalTables*-create-try: "+id); return (InternalTables)Class.forName(id).newInstance(); } *************** *** 42,51 **** static InternalTables createInternalTables() { ! String cands = PySystemState.registry.getProperty("python.options.internalTablesImpl"); if (cands == null) cands = ">2:>1"; else cands = cands + ":>2:>1"; ! java.util.StringTokenizer candEnum = new java.util.StringTokenizer(cands,":"); while (candEnum.hasMoreTokens()) { InternalTables tbl = tryImpl(candEnum.nextToken().trim()); --- 44,54 ---- static InternalTables createInternalTables() { ! String cands = PySystemState.registry.getProperty( ! "python.options.internalTablesImpl"); if (cands == null) cands = ">2:>1"; else cands = cands + ":>2:>1"; ! StringTokenizer candEnum = new StringTokenizer(cands,":"); while (candEnum.hasMoreTokens()) { InternalTables tbl = tryImpl(candEnum.nextToken().trim()); *************** *** 59,64 **** protected abstract PyJavaClass getLazyCanonical(String name); ! protected abstract void putCanonical(Class c,PyJavaClass canonical); ! protected abstract void putLazyCanonical(String name,PyJavaClass canonical); protected abstract Class getAdapterClass(Class c); --- 62,68 ---- protected abstract PyJavaClass getLazyCanonical(String name); ! protected abstract void putCanonical(Class c, PyJavaClass canonical); ! protected abstract void putLazyCanonical(String name, ! PyJavaClass canonical); protected abstract Class getAdapterClass(Class c); Index: MakeProxies.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/MakeProxies.java,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** MakeProxies.java 2001/02/01 16:41:10 2.14 --- MakeProxies.java 2001/02/02 09:28:36 2.15 *************** *** 14,19 **** class MakeProxies { ! private static Class makeClass(Class referent, Vector secondary,String name, ! ByteArrayOutputStream bytes) { Vector referents = null; --- 14,19 ---- class MakeProxies { ! private static Class makeClass(Class referent, Vector secondary, ! String name, ByteArrayOutputStream bytes) { Vector referents = null; Index: PackageManager.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PackageManager.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** PackageManager.java 2001/02/01 16:41:10 2.6 --- PackageManager.java 2001/02/02 09:28:36 2.7 *************** *** 22,26 **** public void notifyPackageImport(String pkg,String name) {} ! /** Dynamically check if pkg.name exists as java pkg in the controlled hierarchy. * Should be overriden. * @param pkg parent pkg name --- 22,27 ---- public void notifyPackageImport(String pkg,String name) {} ! /** Dynamically check if pkg.name exists as java pkg in the ! * controlled hierarchy. * Should be overriden. * @param pkg parent pkg name *************** *** 31,46 **** /** Reports the specified package content names. Should be overriden. ! * Used by {@link PyJavaPackage#__dir__} and {@link PyJavaPackage#fillDir}. * @return resulting list of names (PyList of PyString) ! * @param jpkg queried package ! * @param instantiate if true then instatiate reported names in package dict ! * @param exclpkgs exclude packages (just when instantiate is false) */ ! public abstract PyList doDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs); /** Basic helper implementation of {@link #doDir}. ! * It merges information from jpkg {@link PyJavaPackage#clsSet} and {@link PyJavaPackage#__dict__}. */ ! protected PyList basicDoDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { PyStringMap dict = jpkg.__dict__; PyStringMap cls = jpkg.clsSet; --- 32,53 ---- /** Reports the specified package content names. Should be overriden. ! * Used by {@link PyJavaPackage#__dir__} and ! * {@link PyJavaPackage#fillDir}. * @return resulting list of names (PyList of PyString) ! * @param jpkg queried package ! * @param instantiate if true then instatiate reported names in ! * package dict ! * @param exclpkgs exclude packages (just when instantiate is false) */ ! public abstract PyList doDir(PyJavaPackage jpkg, boolean instantiate, ! boolean exclpkgs); /** Basic helper implementation of {@link #doDir}. ! * It merges information from jpkg {@link PyJavaPackage#clsSet} ! * and {@link PyJavaPackage#__dict__}. */ ! protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate, ! boolean exclpkgs) ! { PyStringMap dict = jpkg.__dict__; PyStringMap cls = jpkg.clsSet; *************** *** 54,58 **** PyObject name = dictKeys.get(i); if (!cls.has_key(name)) { ! if (exclpkgs && dict.get(name) instanceof PyJavaPackage) continue; ret.append(name); } --- 61,66 ---- PyObject name = dictKeys.get(i); if (!cls.has_key(name)) { ! if (exclpkgs && dict.get(name) instanceof PyJavaPackage) ! continue; ret.append(name); } *************** *** 103,107 **** /** Creates package/updates statically known classes info. ! * Uses {@link PyJavaPackage#addPackage(java.lang.String, java.lang.String) }, {@link PyJavaPackage#addPlaceholders}. * * @param name package name --- 111,116 ---- /** Creates package/updates statically known classes info. ! * Uses {@link PyJavaPackage#addPackage(java.lang.String, ! * java.lang.String) }, {@link PyJavaPackage#addPlaceholders}. * * @param name package name *************** *** 110,114 **** * @return created/updated package */ ! public PyJavaPackage makeJavaPackage(String name,String classes,String jarfile) { PyJavaPackage p = topLevelPackage; if(name.length() != 0) p=p.addPackage(name,jarfile); --- 119,125 ---- * @return created/updated package */ ! public PyJavaPackage makeJavaPackage(String name, String classes, ! String jarfile) ! { PyJavaPackage p = topLevelPackage; if(name.length() != 0) p=p.addPackage(name,jarfile); *************** *** 124,128 **** * And return its access permissions as an int. */ ! static protected int checkAccess(java.io.InputStream cstream) throws java.io.IOException { java.io.DataInputStream istream=new java.io.DataInputStream(cstream); --- 135,141 ---- * And return its access permissions as an int. */ ! static protected int checkAccess(java.io.InputStream cstream) ! throws java.io.IOException ! { java.io.DataInputStream istream=new java.io.DataInputStream(cstream); *************** *** 158,163 **** break; default: ! //System.err.println("unexpected cid: "+cid+", "+i+", "+nconstants); ! //for (int j=0; j<10; j++) { System.err.print(", "+istream.readByte()); } //System.err.println(); return -1; --- 171,178 ---- break; default: ! //System.err.println("unexpected cid: "+cid+", "+i+", "+ ! // nconstants); ! //for (int j=0; j<10; j++) ! // System.err.print(", "+istream.readByte()); //System.err.println(); return -1; Index: PathPackageManager.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PathPackageManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** PathPackageManager.java 2001/02/01 16:41:10 1.3 --- PathPackageManager.java 2001/02/02 09:28:36 1.4 *************** *** 7,12 **** import java.lang.reflect.Modifier; ! /** Path package manager. Gathering classes info dynamically from a set of directories ! * in path {@link #searchPath}, and statically from a set of jars, like {@link CachedJarsPackageManager}. */ public abstract class PathPackageManager extends CachedJarsPackageManager { --- 7,13 ---- import java.lang.reflect.Modifier; ! /** Path package manager. Gathering classes info dynamically ! * from a set of directories in path {@link #searchPath}, and ! * statically from a set of jars, like {@link CachedJarsPackageManager}. */ public abstract class PathPackageManager extends CachedJarsPackageManager { *************** *** 23,31 **** */ protected boolean packageExists(PyList path,String pkg,String name) { ! String child = pkg.replace('.',File.separatorChar) + File.separator + name; for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); ! if(dir.length() == 0) dir = null; if (new File(dir,child).isDirectory()) return true; --- 24,33 ---- */ protected boolean packageExists(PyList path,String pkg,String name) { ! String child = pkg.replace('.',File.separatorChar) + ! File.separator + name; for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); ! if (dir.length() == 0) dir = null; if (new File(dir,child).isDirectory()) return true; *************** *** 39,48 **** * Filter out classes using {@link #filterByName},{@link #filterByAccess}. */ ! protected void doDir(PyList path,PyList ret, PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { String child=jpkg.__name__.replace('.',File.separatorChar); for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); ! if(dir.length() == 0) dir = null; File childFile = new File(dir,child); --- 41,52 ---- * Filter out classes using {@link #filterByName},{@link #filterByAccess}. */ ! protected void doDir(PyList path, PyList ret, PyJavaPackage jpkg, ! boolean instantiate,boolean exclpkgs) ! { String child=jpkg.__name__.replace('.',File.separatorChar); for (int i=0; i < path.__len__(); i++) { String dir = path.get(i).__str__().toString(); ! if (dir.length() == 0) dir = null; File childFile = new File(dir,child); *************** *** 75,91 **** // for opt maybe we should some hash-set for ret ! if (jpkg.__dict__.has_key(name) || jpkg.clsSet.has_key(name) || ret.__contains__(name)) { continue; } ! if(!Character.isJavaIdentifierStart(jname.charAt(0))) continue; ! for(int k = 1; k < jlen; k++) { ! if(!Character.isJavaIdentifierPart(jname.charAt(k))) continue doList; } if(!pkgCand) { try { ! int acc = checkAccess(new BufferedInputStream(new FileInputStream(cand))); ! if ((acc == -1) || filterByAccess(jname, acc) ) continue; } catch(IOException e) { continue; --- 79,101 ---- // for opt maybe we should some hash-set for ret ! if (jpkg.__dict__.has_key(name) || ! jpkg.clsSet.has_key(name) || ! ret.__contains__(name)) { continue; } ! if (!Character.isJavaIdentifierStart(jname.charAt(0))) ! continue; ! for (int k = 1; k < jlen; k++) { ! if (!Character.isJavaIdentifierPart(jname.charAt(k))) ! continue doList; } if(!pkgCand) { try { ! int acc = checkAccess(new BufferedInputStream( ! new FileInputStream(cand))); ! if ((acc == -1) || filterByAccess(jname, acc)) ! continue; } catch(IOException e) { continue; *************** *** 93,98 **** } ! if(instantiate) { ! if(pkgCand) jpkg.addPackage(jname); else jpkg.addLazyClass(jname); } --- 103,108 ---- } ! if (instantiate) { ! if (pkgCand) jpkg.addPackage(jname); else jpkg.addLazyClass(jname); } *************** *** 109,114 **** public void addDirectory(File dir) { try { ! if (dir.getPath().length() == 0) searchPath.append(Py.EmptyString); ! else searchPath.append(new PyString(dir.getCanonicalPath())); } catch(IOException e) { warning("skipping bad directory, '" +dir+ "'"); --- 119,126 ---- public void addDirectory(File dir) { try { ! if (dir.getPath().length() == 0) ! searchPath.append(Py.EmptyString); ! else ! searchPath.append(new PyString(dir.getCanonicalPath())); } catch(IOException e) { warning("skipping bad directory, '" +dir+ "'"); *************** *** 118,129 **** // ??pending: ! // Uses simply split and not a StringTokenizer+trim to adhere to sun jvm parsing of classpath. ! // E.g. "a;" is parsed by sun jvm as a, ""; the latter is interpreted as cwd. ! // jview trims and cwd is per default in classpath. The logic here should work ! // for both(...). Need to distinguish? ! // This code does not avoid duplicates in searchPath. Should cause no problem (?). ! /** Adds "classpath" entry. Calls {@link #addDirectory} if path refers to a dir, {@link #addJarToPackages(java.io.File, boolean)} ! with param cache true if path refers to a jar. ! */ public void addClassPath(String path) { PyList paths = new PyString(path).split(java.io.File.pathSeparator); --- 130,145 ---- // ??pending: ! // Uses simply split and not a StringTokenizer+trim to adhere to ! // sun jvm parsing of classpath. ! // E.g. "a;" is parsed by sun jvm as a, ""; the latter is interpreted ! // as cwd. jview trims and cwd is per default in classpath. ! // The logic here should work for both(...). Need to distinguish? ! // This code does not avoid duplicates in searchPath. ! // Should cause no problem (?). ! ! /** Adds "classpath" entry. Calls {@link #addDirectory} if path ! * refers to a dir, {@link #addJarToPackages(java.io.File, boolean)} ! * with param cache true if path refers to a jar. ! */ public void addClassPath(String path) { PyList paths = new PyString(path).split(java.io.File.pathSeparator); *************** *** 135,144 **** } else { File dir = new File(entry); ! if (entry.length() == 0 || dir.isDirectory()) addDirectory(dir); } } } ! public PyList doDir(PyJavaPackage jpkg,boolean instantiate,boolean exclpkgs) { PyList basic = basicDoDir(jpkg,instantiate,exclpkgs); PyList ret = new PyList(); --- 151,163 ---- } else { File dir = new File(entry); ! if (entry.length() == 0 || dir.isDirectory()) ! addDirectory(dir); } } } ! public PyList doDir(PyJavaPackage jpkg, boolean instantiate, ! boolean exclpkgs) ! { PyList basic = basicDoDir(jpkg,instantiate,exclpkgs); PyList ret = new PyList(); Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** Py.java 2001/02/01 16:41:10 2.33 --- Py.java 2001/02/02 09:28:36 2.34 *************** *** 19,23 **** public static PyObject None; ! /** The singleton Ellipsis Python object - written as ... when indexing **/ public static PyObject Ellipsis; --- 19,23 ---- public static PyObject None; ! /** The singleton Ellipsis Python object - written as ... when indexing */ public static PyObject Ellipsis; *************** *** 263,267 **** } ! // ??pending: was @deprecated but is actually used by proxie code. Can get rid of it? public static Object tojava(PyObject o, String s) { Class c = findClass(s); --- 263,268 ---- } ! // ??pending: was @deprecated but is actually used by proxie code. ! // Can get rid of it? public static Object tojava(PyObject o, String s) { Class c = findClass(s); *************** *** 281,285 **** return null; ! // Set the current system state to match proxy -- usually this is a waste of time :-( Py.setSystemState(proxy._getPySystemState()); return ret; --- 282,287 ---- return null; ! // Set the current system state to match proxy -- usually ! // this is a waste of time :-( Py.setSystemState(proxy._getPySystemState()); return ret; *************** *** 593,597 **** ClassLoader classLoader = Py.getSystemState().getClassLoader(); if (classLoader != null) { ! writeDebug("import", "trying " + name + " as " + reason + " in classLoader"); return classLoader.loadClass(name); } --- 595,600 ---- ClassLoader classLoader = Py.getSystemState().getClassLoader(); if (classLoader != null) { ! writeDebug("import", "trying " + name + " as " + reason + ! " in classLoader"); return classLoader.loadClass(name); } *************** *** 604,612 **** secEnv=true; } ! writeDebug("import", "trying " + name + " as " + reason + " in syspath loader"); return classLoader.loadClass(name); } ! writeDebug("import", "trying " + name + " as " + reason + " in Class.forName"); return Class.forName(name); } --- 607,617 ---- secEnv=true; } ! writeDebug("import", "trying " + name + " as " + reason + ! " in syspath loader"); return classLoader.loadClass(name); } ! writeDebug("import", "trying " + name + " as " + reason + ! " in Class.forName"); return Class.forName(name); } *************** *** 720,724 **** PyObject mod; ! Class modClass = Py.findClass(module+"$_PyInner"); // ??pending: findClass or should avoid sys.path loading? if (modClass != null) { //System.err.println("found as class: "+modClass); --- 725,730 ---- PyObject mod; ! // ??pending: findClass or should avoid sys.path loading? ! Class modClass = Py.findClass(module+"$_PyInner"); if (modClass != null) { //System.err.println("found as class: "+modClass); *************** *** 755,759 **** Class mainClass=null; try { ! mainClass = Class.forName(module); // ??pending: should use Py.findClass? } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); --- 761,766 ---- Class mainClass=null; try { ! // ??pending: should use Py.findClass? ! mainClass = Class.forName(module); } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); *************** *** 770,774 **** } ! public static void runMain(String module, String[] args, String[] packages, String[] props, String frozenPackage, --- 777,782 ---- } ! public static void runMain(String module, String[] args, ! String[] packages, String[] props, String frozenPackage, *************** *** 779,783 **** Class mainClass=null; try { ! mainClass = Class.forName(module); // ??pending: should use Py.findClass? } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); --- 787,792 ---- Class mainClass=null; try { ! // ??pending: should use Py.findClass? ! mainClass = Class.forName(module); } catch (ClassNotFoundException exc) { System.err.println("Error running main. Can't find: "+module); *************** *** 1101,1105 **** PySystemState oldSystemState = ts.systemState; if (oldSystemState != newSystemState) { ! //System.err.println("Warning: changing systemState for same thread!"); ts.systemState = newSystemState; } --- 1110,1115 ---- PySystemState oldSystemState = ts.systemState; if (oldSystemState != newSystemState) { ! //System.err.println("Warning: changing systemState "+ ! // "for same thread!"); ts.systemState = newSystemState; } *************** *** 1398,1408 **** } ! public static PyCode compile(SimpleNode node, String name, String filename) { return compile(node, name, filename, true, false); } ! public static PyCode compile(SimpleNode node, String name, String filename, ! boolean linenumbers, boolean printResults) { try { --- 1408,1421 ---- } ! public static PyCode compile(SimpleNode node, String name, ! String filename) { return compile(node, name, filename, true, false); } ! public static PyCode compile(SimpleNode node, String name, ! String filename, ! boolean linenumbers, ! boolean printResults) { try { Index: PyBeanEventProperty.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyBeanEventProperty.java,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** PyBeanEventProperty.java 2001/02/01 16:41:10 2.4 --- PyBeanEventProperty.java 2001/02/02 09:28:36 2.5 *************** *** 62,66 **** Class pc = Py.findClass("org.python.proxies."+c.getName()+"$Adapter"); if (pc == null) { ! //System.err.println("adapter not found for: "+"org.python.proxies."+c.getName()+"$Adapter"); pc = MakeProxies.makeAdapter(c); } --- 62,68 ---- Class pc = Py.findClass("org.python.proxies."+c.getName()+"$Adapter"); if (pc == null) { ! //System.err.println("adapter not found for: "+ ! // "org.python.proxies."+ ! // c.getName()+"$Adapter"); pc = MakeProxies.makeAdapter(c); } Index: PyClass.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyClass.java,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** PyClass.java 2001/02/01 16:41:10 2.17 --- PyClass.java 2001/02/02 09:28:36 2.18 *************** *** 69,85 **** Class baseClass = null; for (int i=0; i<bases.list.length; i++) { ! Class previousProxy = ((PyClass)bases.list[i]).getProxyClass(); ! if (previousProxy != null) { ! if (previousProxy.isInterface()) { ! interfaces.addElement(previousProxy); } else { if (baseClass != null) { throw Py.TypeError("no multiple inheritance "+ "for Java classes: "+ ! previousProxy.getName()+ " and "+ baseClass.getName()); } ! baseClass = previousProxy; } } --- 69,85 ---- Class baseClass = null; for (int i=0; i<bases.list.length; i++) { ! Class proxy = ((PyClass)bases.list[i]).getProxyClass(); ! if (proxy != null) { ! if (proxy.isInterface()) { ! interfaces.addElement(proxy); } else { if (baseClass != null) { throw Py.TypeError("no multiple inheritance "+ "for Java classes: "+ ! proxy.getName()+ " and "+ baseClass.getName()); } ! baseClass = proxy; } } *************** *** 108,112 **** } } ! //System.out.println("proxyClasses: "+proxyClasses+", "+proxyClasses[0]); if (dict.__finditem__("__doc__") == null) { dict.__setitem__("__doc__", Py.None); --- 108,113 ---- } } ! //System.out.println("proxyClasses: "+proxyClasses+", "+ ! // proxyClasses[0]); if (dict.__finditem__("__doc__") == null) { dict.__setitem__("__doc__", Py.None); *************** *** 151,155 **** resolvedClass = (PyClass)(__bases__.__getitem__(i)); PyObject[] res = resolvedClass.lookupGivingClass(name, ! stop_at_java); result = res[0]; resolvedClass = (PyClass)(res[1]); --- 152,156 ---- resolvedClass = (PyClass)(__bases__.__getitem__(i)); PyObject[] res = resolvedClass.lookupGivingClass(name, ! stop_at_java); result = res[0]; resolvedClass = (PyClass)(res[1]); *************** *** 200,204 **** inst.__init__(args, keywords); ! if (proxyClass != null && PyObject.class.isAssignableFrom(proxyClass)) { // It would be better if we didn't have to create a PyInstance // in the first place. --- 201,206 ---- inst.__init__(args, keywords); ! if (proxyClass != null && ! PyObject.class.isAssignableFrom(proxyClass)) { // It would be better if we didn't have to create a PyInstance // in the first place. Index: PyComplex.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyComplex.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** PyComplex.java 2001/02/01 16:41:10 2.3 --- PyComplex.java 2001/02/02 09:28:36 2.4 *************** *** 209,213 **** z.imag = 0.0; ! return new PyTuple(new PyObject[] {z, value.__sub__(z.__mul__(right))}); } --- 209,214 ---- z.imag = 0.0; ! return new PyTuple(new PyObject[] ! { z, value.__sub__(z.__mul__(right))}); } Index: PyFile.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** PyFile.java 2001/02/01 16:41:10 2.14 --- PyFile.java 2001/02/02 09:28:36 2.15 *************** *** 302,316 **** int extraCopy = len - copyLength; ! // If the amount remaining is more than a buffer's length, read it ! // directly from the file. if (extraCopy > buffer.length) { file.seek(filePosition); ! extraCopy = file.read( b, off + copyLength, len - copyLength ); } else { ! // ...or read a new buffer full, and copy as much as possible... seek(filePosition, 0); if (!endOfFile) { ! extraCopy = (extraCopy > dataSize) ? dataSize : extraCopy; ! System.arraycopy(buffer, 0, b, off + copyLength, extraCopy); } else { extraCopy = -1; --- 302,320 ---- int extraCopy = len - copyLength; ! // If the amount remaining is more than a buffer's ! // length, read it directly from the file. if (extraCopy > buffer.length) { file.seek(filePosition); ! extraCopy = file.read(b, off + copyLength, ! len - copyLength); } else { ! // ...or read a new buffer full, and copy as much ! // as possible... seek(filePosition, 0); if (!endOfFile) { ! extraCopy = (extraCopy > dataSize) ? ! dataSize : extraCopy; ! System.arraycopy(buffer, 0, b, off + copyLength, ! extraCopy); } else { extraCopy = -1; *************** *** 318,323 **** } ! // If we did manage to copy any more, update the file position and ! // return the amount copied. if (extraCopy > 0) { filePosition += extraCopy; --- 322,327 ---- } ! // If we did manage to copy any more, update the file ! // position and return the amount copied. if (extraCopy > 0) { filePosition += extraCopy; *************** *** 334,345 **** // If the file position is within the data, return the byte... if (filePosition < dataEnd) { ! return (int)(buffer[(int)(filePosition++ - bufferStart)] & 0xff); ! ! // ...or should we indicate EOF... } else if (endOfFile) { return -1; - - // ...or seek to fill the buffer, and try again. } else { seek(filePosition, 0); return read(); --- 338,348 ---- // If the file position is within the data, return the byte... if (filePosition < dataEnd) { ! return (int)(buffer[(int)(filePosition++ - bufferStart)] ! & 0xff); } else if (endOfFile) { + // ...or should we indicate EOF... return -1; } else { + // ...or seek to fill the buffer, and try again. seek(filePosition, 0); return read(); *************** *** 365,374 **** int copyLength = 0; if (filePosition >= bufferStart) ! spaceInBuffer = (int)((bufferStart + buffer.length) - filePosition); if (spaceInBuffer > 0) { // Copy as much as possible to the buffer. ! copyLength = (spaceInBuffer > len) ? len : spaceInBuffer; System.arraycopy(b, 0, buffer, ! (int)(filePosition - bufferStart), copyLength ); bufferModified = true; long myDataEnd = filePosition + copyLength; --- 368,380 ---- int copyLength = 0; if (filePosition >= bufferStart) ! spaceInBuffer = (int)((bufferStart + buffer.length) - ! filePosition); if (spaceInBuffer > 0) { // Copy as much as possible to the buffer. ! copyLength = (spaceInBuffer > len) ? ! len : spaceInBuffer; System.arraycopy(b, 0, buffer, ! (int)(filePosition - bufferStart), ! copyLength ); bufferModified = true; long myDataEnd = filePosition + copyLength; *************** *** 378,383 **** } ! // If there is any data remaining, move to the new position and copy to ! // the new buffer. if (copyLength < len) { seek(filePosition, 0); --- 384,389 ---- } ! // If there is any data remaining, move to the ! // new position and copy to the new buffer. if (copyLength < len) { seek(filePosition, 0); *************** *** 807,811 **** for (int i = 0; (item = a.__finditem__(i)) != null; i++) { if (!(item instanceof PyString)) ! throw Py.TypeError("writelines() argument must be a sequence of strings"); write(item.toString()); } --- 813,818 ---- for (int i = 0; (item = a.__finditem__(i)) != null; i++) { if (!(item instanceof PyString)) ! throw Py.TypeError("writelines() argument must be a " + ! "sequence of strings"); write(item.toString()); } *************** *** 863,867 **** public String toString() { ! return "<file " + name + ", mode " + mode + " at " + Py.id(this) + ">"; } --- 870,875 ---- public String toString() { ! return "<file " + name + ", mode " + mode + " at " + ! Py.id(this) + ">"; } Index: PyFloat.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFloat.java,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** PyFloat.java 2001/02/01 16:41:10 2.5 --- PyFloat.java 2001/02/02 09:28:36 2.6 *************** *** 45,53 **** if (fractPart == 0) { ! if (intPart <= Integer.MAX_VALUE && intPart >= Integer.MIN_VALUE) { return (int)value; ! } else { return __long__().hashCode(); - } } else { long v = Double.doubleToLongBits(value); --- 45,52 ---- if (fractPart == 0) { ! if (intPart <= Integer.MAX_VALUE && intPart >= Integer.MIN_VALUE) return (int)value; ! else return __long__().hashCode(); } else { long v = Double.doubleToLongBits(value); *************** *** 239,243 **** if (value == 0.0) { if (iw < 0.0) ! throw Py.ZeroDivisionError("0.0 cannot be raised to a negative power"); return new PyFloat(0); } --- 238,243 ---- if (value == 0.0) { if (iw < 0.0) ! throw Py.ZeroDivisionError("0.0 cannot be raised to a " + ! "negative power"); return new PyFloat(0); } Index: PyFunction.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFunction.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** PyFunction.java 2001/02/01 16:41:10 2.6 --- PyFunction.java 2001/02/02 09:28:36 2.7 *************** *** 147,151 **** return func_code.call(args, keywords, func_globals, func_defaults); } ! public PyObject __call__(PyObject arg1, PyObject[] args, String[] keywords) { return func_code.call(arg1, args, keywords, func_globals, --- 147,152 ---- return func_code.call(args, keywords, func_globals, func_defaults); } ! public PyObject __call__(PyObject arg1, PyObject[] args, ! String[] keywords) { return func_code.call(arg1, args, keywords, func_globals, Index: PyInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInstance.java,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** PyInstance.java 2001/02/01 16:41:10 2.16 --- PyInstance.java 2001/02/02 09:28:36 2.17 *************** *** 180,198 **** } - /*private PyProxy createProxy(Class c) { - try { - return (PyProxy)c.getConstructor(new Class[] {PyInstance.class}).newInstance(new Object[] {this}); - } catch (Exception exc) { - throw Py.JavaError(exc); - } - }*/ - - /*public PyObject __jgetattr__(String name) { - System.err.println("jgetting: "+name); - PyObject ret = __findattr__(name, true); - if (ret != null) return ret; - throw Py.AttributeError(name); - }*/ - public PyObject __jfindattr__(String name) { //System.err.println("jfinding: "+name); --- 180,183 ---- Index: PyInteger.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInteger.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** PyInteger.java 2001/02/01 16:41:10 2.7 --- PyInteger.java 2001/02/02 09:28:36 2.8 *************** *** 224,230 **** if (pow < 0) { if (value != 0) ! throw Py.ValueError("cannot raise integer to a negative power"); else ! throw Py.ZeroDivisionError("cannot raise 0 to a negative power"); } --- 224,232 ---- if (pow < 0) { if (value != 0) ! throw Py.ValueError("cannot raise integer to a " + ! "negative power"); else ! throw Py.ZeroDivisionError("cannot raise 0 to a " + ! "negative power"); } Index: PyJavaClass.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaClass.java,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** PyJavaClass.java 2001/02/01 16:41:10 2.31 --- PyJavaClass.java 2001/02/02 09:28:36 2.32 *************** *** 109,113 **** } catch (Exception exc) { ! // System.err.println("Got exception: " + exc + " " + proxyClass); throw Py.JavaError(exc); } --- 109,114 ---- } catch (Exception exc) { ! // System.err.println("Got exception: " + exc + " " + ! // proxyClass); throw Py.JavaError(exc); } *************** *** 146,162 **** if (!PyObject.class.isAssignableFrom(c)) return; - - // // Handle the special static __class__ fields on PyObject instances - // if (name == "__class__" && isstatic && - // PyObject.class.isAssignableFrom(field.getDeclaringClass()) && - // field.getType().isAssignableFrom(PyJavaClass.class)) { - // try { - // field.set(null, this); - // continue; - // } catch (Throwable t) { - // System.err.println("invalid __class__ field on: "+c.getName()); - // } - // } - try { Field field = c.getField("__class__"); --- 147,150 ---- *************** *** 786,790 **** inst.__init__(args, keywords); ! if (proxyClass != null && PyObject.class.isAssignableFrom(proxyClass)) { // It would be better if we didn't have to create a PyInstance // in the first place. --- 774,779 ---- inst.__init__(args, keywords); ! if (proxyClass != null && ! PyObject.class.isAssignableFrom(proxyClass)) { // It would be better if we didn't have to create a PyInstance // in the first place. Index: PyJavaInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaInstance.java,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** PyJavaInstance.java 2001/02/01 16:41:10 2.3 --- PyJavaInstance.java 2001/02/02 09:28:37 2.4 *************** *** 68,73 **** protected void unassignableField(String name, PyObject value) { ! throw Py.TypeError("can't assign to this attribute in java instance: "+ ! name); } --- 68,73 ---- protected void unassignableField(String name, PyObject value) { ! throw Py.TypeError("can't assign to this attribute in java " + ! "instance: " + name); } Index: PyJavaPackage.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyJavaPackage.java,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** PyJavaPackage.java 2001/02/01 16:41:10 2.8 --- PyJavaPackage.java 2001/02/02 09:28:37 2.9 *************** *** 70,77 **** PyJavaPackage p = (PyJavaPackage)__dict__.__finditem__(firstName); if (p == null) { ! p = new PyJavaPacka... [truncated message content] |