From: <pj...@us...> - 2009-05-11 00:48:55
|
Revision: 6333 http://jython.svn.sourceforge.net/jython/?rev=6333&view=rev Author: pjenvey Date: 2009-05-11 00:48:39 +0000 (Mon, 11 May 2009) Log Message: ----------- coding standards/cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyBuiltinMethodSet.java Modified: trunk/jython/src/org/python/core/PyBuiltinMethodSet.java =================================================================== --- trunk/jython/src/org/python/core/PyBuiltinMethodSet.java 2009-05-10 21:44:46 UTC (rev 6332) +++ trunk/jython/src/org/python/core/PyBuiltinMethodSet.java 2009-05-11 00:48:39 UTC (rev 6333) @@ -1,54 +1,55 @@ +/* Copyright (c) Jython Developers */ package org.python.core; -public class PyBuiltinMethodSet extends PyBuiltinFunctionSet implements - Cloneable { +public class PyBuiltinMethodSet extends PyBuiltinFunctionSet implements Cloneable { - public PyBuiltinMethodSet(String name, - int index, - int minargs, - int maxargs, - String doc, - Class type) { + private Class<?> type; + + protected PyObject __self__ = Py.None; + + public PyBuiltinMethodSet(String name, int index, int minargs, int maxargs, String doc, + Class<?> type) { super(name, index, minargs, maxargs, doc); this.type = type; } + @Override public PyObject __get__(PyObject obj, PyObject type) { - if(obj != null) { - if(this.type.isAssignableFrom(obj.getClass())) { + if (obj != null) { + if (this.type.isAssignableFrom(obj.getClass())) { return bind(obj); } else { - throw Py.TypeError("descriptor '" + info.getName() + "' for '" + PyType.fromClass(this.type) - + "' objects doesn't apply to '" + obj.getType() + "' object"); + throw Py.TypeError(String.format("descriptor '%s' for '%s' objects doesn't apply " + + "to '%s' object", info.getName(), + PyType.fromClass(this.type), obj.getType())); } } return this; } + @Override public PyBuiltinCallable bind(PyObject bindTo) { - if(__self__ == Py.None) { - PyBuiltinMethodSet bindable; - try { - bindable = (PyBuiltinMethodSet)clone(); - } catch(CloneNotSupportedException e) { - throw new RuntimeException("Didn't expect PyBuiltinMethodSet to throw CloneNotSupported since it implements Cloneable", - e); - } - bindable.__self__ = bindTo; - return bindable; + if (__self__ != Py.None) { + return this; } - return this; + PyBuiltinMethodSet bindable; + try { + bindable = (PyBuiltinMethodSet)clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException("Didn't expect PyBuiltinMethodSet to throw " + + "CloneNotSupported since it implements Cloneable", e); + } + bindable.__self__ = bindTo; + return bindable; } + @Override public PyObject getSelf() { return __self__; } - - public String toString(){ - return "<built-in method "+info.getName()+">"; + + @Override + public String toString() { + return String.format("<built-in method %s>", info.getName()); } - - private Class type; - - protected PyObject __self__ = Py.None; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-04-10 19:47:25
|
Revision: 7013 http://jython.svn.sourceforge.net/jython/?rev=7013&view=rev Author: pjenvey Date: 2010-04-10 19:47:19 +0000 (Sat, 10 Apr 2010) Log Message: ----------- force __get__ on PyBuiltinMethodSet as its Java subclasses don't always allow visibility of __get__ via reflection Modified Paths: -------------- trunk/jython/src/org/python/core/PyBuiltinMethodSet.java Modified: trunk/jython/src/org/python/core/PyBuiltinMethodSet.java =================================================================== --- trunk/jython/src/org/python/core/PyBuiltinMethodSet.java 2010-04-10 02:13:10 UTC (rev 7012) +++ trunk/jython/src/org/python/core/PyBuiltinMethodSet.java 2010-04-10 19:47:19 UTC (rev 7013) @@ -49,6 +49,11 @@ } @Override + public boolean implementsDescrGet() { + return true; + } + + @Override public String toString() { return String.format("<built-in method %s>", info.getName()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |