Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(64)

Side by Side Diff: src/org/python/core/PyClass.java

Issue 2888: __findattr__ refactor (Closed) SVN Base: https://jython.svn.sourceforge.net/svnroot/jython/branches/asm
Patch Set: This is the actually commited patch (on r5155), in case you have more comments Created 1 year, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) Corporation for National Research Initiatives 1 // Copyright (c) Corporation for National Research Initiatives
2 package org.python.core; 2 package org.python.core;
3 3
4 import java.io.Serializable; 4 import java.io.Serializable;
5 import java.util.ArrayList; 5 import java.util.ArrayList;
6 import java.util.List; 6 import java.util.List;
7 7
8 /** 8 /**
9 * A python class. 9 * A python class.
10 */ 10 */
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 public PyObject fastGetDict() { 222 public PyObject fastGetDict() {
223 return __dict__; 223 return __dict__;
224 } 224 }
225 225
226 PyObject lookup(String name, boolean stop_at_java) { 226 PyObject lookup(String name, boolean stop_at_java) {
227 PyObject[] result = lookupGivingClass(name, stop_at_java); 227 PyObject[] result = lookupGivingClass(name, stop_at_java);
228 return result[0]; 228 return result[0];
229 } 229 }
230 230
231 public PyObject __findattr__(String name) { 231 public PyObject __findattr_ex__(String name) {
232 if (name == "__dict__") { 232 if (name == "__dict__") {
233 return __dict__; 233 return __dict__;
234 } 234 }
235 if (name == "__name__") { 235 if (name == "__name__") {
236 return new PyString(__name__); 236 return new PyString(__name__);
237 } 237 }
238 if (name == "__bases__") { 238 if (name == "__bases__") {
239 return __bases__; 239 return __bases__;
240 } 240 }
241 if (name == "__class__") { 241 if (name == "__class__") {
242 return null; 242 return null;
243 } 243 }
244 244
245 PyObject[] result = lookupGivingClass(name, false); 245 PyObject[] result = lookupGivingClass(name, false);
246 246
247 if (result[0] == null) { 247 if (result[0] == null) {
248 return super.__findattr__(name); 248 return super.__findattr_ex__(name);
249 } 249 }
250 // xxx do we need to use result[1] (wherefound) for java cases for backw 250 // xxx do we need to use result[1] (wherefound) for java cases for backw
251 // comp? 251 // comp?
252 return result[0].__get__(null, this); 252 return result[0].__get__(null, this);
253 } 253 }
254 254
255 public void __setattr__(String name, PyObject value) { 255 public void __setattr__(String name, PyObject value) {
256 if (name == "__dict__") { 256 if (name == "__dict__") {
257 if (!value.isMappingType()) 257 if (!value.isMappingType())
258 throw Py.TypeError("__dict__ must be a dictionary object"); 258 throw Py.TypeError("__dict__ must be a dictionary object");
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 int n = bases.length; 361 int n = bases.length;
362 for (int i = 0; i < n; i++) { 362 for (int i = 0; i < n; i++) {
363 PyClass c = (PyClass) bases[i]; 363 PyClass c = (PyClass) bases[i];
364 if (c.isSubClass(superclass)) { 364 if (c.isSubClass(superclass)) {
365 return true; 365 return true;
366 } 366 }
367 } 367 }
368 return false; 368 return false;
369 } 369 }
370 } 370 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497