From: <pj...@us...> - 2009-10-29 07:19:39
|
Revision: 6932 http://jython.svn.sourceforge.net/jython/?rev=6932&view=rev Author: pjenvey Date: 2009-10-29 07:19:33 +0000 (Thu, 29 Oct 2009) Log Message: ----------- getJavaProxy with a fallback seems to do what we need a little more efficiently than __tojava__, + cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyReflectedField.java Modified: trunk/jython/src/org/python/core/PyReflectedField.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedField.java 2009-10-29 06:58:50 UTC (rev 6931) +++ trunk/jython/src/org/python/core/PyReflectedField.java 2009-10-29 07:19:33 UTC (rev 6932) @@ -1,13 +1,18 @@ -// Copyright (c) Corporation for National Research Initiatives +/* + * Copyright (c) Corporation for National Research Initiatives + * Copyright (c) Jython Developers + */ package org.python.core; import java.lang.reflect.Field; import java.lang.reflect.Modifier; public class PyReflectedField extends PyObject { + public Field field; - public PyReflectedField() {} + public PyReflectedField() { + } public PyReflectedField(Field field) { this.field = field; @@ -17,9 +22,13 @@ public PyObject _doget(PyObject self) { Object iself = null; if (!Modifier.isStatic(field.getModifiers())) { - if (self == null) + if (self == null) { return this; - iself = Py.tojava(self, field.getDeclaringClass()); + } + iself = self.getJavaProxy(); + if (iself == null) { + iself = self; + } } Object value; @@ -37,10 +46,12 @@ Object iself = null; if (!Modifier.isStatic(field.getModifiers())) { if (self == null) { - throw Py.AttributeError("set instance variable as static: "+ - field.toString()); + throw Py.AttributeError("set instance variable as static: " + field.toString()); } - iself = Py.tojava(self, field.getDeclaringClass()); + iself = self.getJavaProxy(); + if (iself == null) { + iself = self; + } } Object fvalue = Py.tojava(value, field.getType()); @@ -54,6 +65,6 @@ @Override public String toString() { - return "<reflected field "+field.toString()+" "+Py.idstr(this)+">"; + return String.format("<reflected field %s at %s>", field, Py.idstr(this)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |