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. |