OLD | NEW |
1 /* Generated file, do not modify. See jython/src/templates/gderived.py. */ | 1 /* Generated file, do not modify. See jython/src/templates/gderived.py. */ |
2 package org.python.modules.collections; | 2 package org.python.modules.collections; |
3 | 3 |
4 import org.python.core.*; | 4 import org.python.core.*; |
5 | 5 |
6 public class PyDequeDerived extends PyDeque implements Slotted { | 6 public class PyDequeDerived extends PyDeque implements Slotted { |
7 | 7 |
8 public PyObject getSlot(int index) { | 8 public PyObject getSlot(int index) { |
9 return slots[index]; | 9 return slots[index]; |
10 } | 10 } |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 PyType self_type=getType(); | 967 PyType self_type=getType(); |
968 PyObject impl=self_type.lookup("__call__"); | 968 PyObject impl=self_type.lookup("__call__"); |
969 if (impl!=null) | 969 if (impl!=null) |
970 return impl.__get__(this,self_type).__call__(args,keywords); | 970 return impl.__get__(this,self_type).__call__(args,keywords); |
971 return super.__call__(args,keywords); | 971 return super.__call__(args,keywords); |
972 } finally { | 972 } finally { |
973 --ts.recursion_depth; | 973 --ts.recursion_depth; |
974 } | 974 } |
975 } | 975 } |
976 | 976 |
977 public PyObject __findattr__(String name) { | 977 public PyObject __findattr_ex__(String name) { |
978 PyType self_type=getType(); | 978 PyType self_type=getType(); |
| 979 // TODO: We should speed this up. As the __getattribute__ slot almost ne
ver |
| 980 // changes, it is a good candidate for caching, as PyClass does wi
th |
| 981 // __getattr__. See #1102. |
979 PyObject getattribute=self_type.lookup("__getattribute__"); | 982 PyObject getattribute=self_type.lookup("__getattribute__"); |
980 PyString py_name=null; | 983 PyString py_name=null; |
| 984 PyException firstAttributeError=null; |
981 try { | 985 try { |
982 if (getattribute!=null) { | 986 if (getattribute!=null) { |
983 return getattribute.__get__(this,self_type).__call__(py_name=PyS
tring.fromInterned(name)); | 987 py_name=PyString.fromInterned(name); |
| 988 return getattribute.__get__(this,self_type).__call__(py_name); |
984 } else { | 989 } else { |
985 return super.__findattr__(name); | 990 Py.Warning(String.format("__getattribute__ not found on type %s"
,self_type.getName())); |
| 991 PyObject ret=super.__findattr_ex__(name); |
| 992 if (ret!=null) { |
| 993 return ret; |
| 994 } // else: pass through to __getitem__ invocation |
986 } | 995 } |
987 } catch (PyException e) { | 996 } catch (PyException e) { |
988 if (Py.matchException(e,Py.AttributeError)) { | 997 if (!Py.matchException(e,Py.AttributeError)) { |
989 PyObject getattr=self_type.lookup("__getattr__"); | 998 throw e; |
990 if (getattr!=null) | 999 } else { |
991 try { | 1000 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors |
992 return getattr.__get__(this,self_type).__call__(py_name!
=null?py_name:PyString.fromInterned(name)); | 1001 // and pass through to __getattr__ invocation. |
993 } catch (PyException e1) { | |
994 if (!Py.matchException(e1,Py.AttributeError)) | |
995 throw e1; | |
996 } | |
997 return null; | |
998 } | 1002 } |
999 throw e; | |
1000 } | 1003 } |
| 1004 PyObject getattr=self_type.lookup("__getattr__"); |
| 1005 if (getattr!=null) { |
| 1006 if (py_name==null) { |
| 1007 py_name=PyString.fromInterned(name); |
| 1008 } |
| 1009 return getattr.__get__(this,self_type).__call__(py_name); |
| 1010 } |
| 1011 if (firstAttributeError!=null) { |
| 1012 throw firstAttributeError; |
| 1013 } |
| 1014 return null; |
1001 } | 1015 } |
1002 | 1016 |
1003 public void __setattr__(String name,PyObject value) { | 1017 public void __setattr__(String name,PyObject value) { |
1004 PyType self_type=getType(); | 1018 PyType self_type=getType(); |
1005 PyObject impl=self_type.lookup("__setattr__"); | 1019 PyObject impl=self_type.lookup("__setattr__"); |
1006 if (impl!=null) { | 1020 if (impl!=null) { |
1007 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); | 1021 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); |
1008 return; | 1022 return; |
1009 } | 1023 } |
1010 super.__setattr__(name,value); | 1024 super.__setattr__(name,value); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 if (impl!=null) { | 1147 if (impl!=null) { |
1134 PyObject res=impl.__get__(this,self_type).__call__(); | 1148 PyObject res=impl.__get__(this,self_type).__call__(); |
1135 if (!(res instanceof PyString)) | 1149 if (!(res instanceof PyString)) |
1136 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); | 1150 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); |
1137 return((PyString)res).toString(); | 1151 return((PyString)res).toString(); |
1138 } | 1152 } |
1139 return super.toString(); | 1153 return super.toString(); |
1140 } | 1154 } |
1141 | 1155 |
1142 } | 1156 } |
OLD | NEW |