LEFT | RIGHT |
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 PyDefaultDictDerived extends PyDefaultDict implements Slotted { | 6 public class PyDefaultDictDerived extends PyDefaultDict 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ex__(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; |
981 PyException firstAttributeError=null; | 984 PyException firstAttributeError=null; |
982 try { | 985 try { |
983 if (getattribute!=null) { | 986 if (getattribute!=null) { |
984 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); |
985 } else { | 989 } else { |
986 // XXX: This shouldn't happen, becase PyObject exposes | 990 Py.Warning(String.format("__getattribute__ not found on type %s"
,self_type.getName())); |
987 // __getattribute__.· | |
988 // | |
989 // And, by the way, invoking object__getattribute__ is the· | |
990 // common case. We should optimize that to avoid doing the | |
991 // '__getattribute__' lookup each time.· | |
992 PyObject ret=super.__findattr_ex__(name); | 991 PyObject ret=super.__findattr_ex__(name); |
993 if (ret!=null) { | 992 if (ret!=null) { |
994 return ret; | 993 return ret; |
995 } // else: pass through to __getitem__ invocation | 994 } // else: pass through to __getitem__ invocation |
996 } | 995 } |
997 } catch (PyException e) { | 996 } catch (PyException e) { |
998 if (!Py.matchException(e,Py.AttributeError)) { | 997 if (!Py.matchException(e,Py.AttributeError)) { |
999 throw e; | 998 throw e; |
1000 } else { | 999 } else { |
1001 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors | 1000 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors |
1002 // and pass through to __getattr__ invocation. | 1001 // and pass through to __getattr__ invocation. |
1003 } | 1002 } |
1004 } | 1003 } |
1005 PyObject getattr=self_type.lookup("__getattr__"); | 1004 PyObject getattr=self_type.lookup("__getattr__"); |
1006 if (getattr!=null) { | 1005 if (getattr!=null) { |
1007 return getattr.__get__(this,self_type).__call__(py_name!=null?py_nam
e:PyString.fromInterned(name)); | 1006 if (py_name==null) { |
| 1007 py_name=PyString.fromInterned(name); |
| 1008 } |
| 1009 return getattr.__get__(this,self_type).__call__(py_name); |
1008 } | 1010 } |
1009 if (firstAttributeError!=null) { | 1011 if (firstAttributeError!=null) { |
1010 throw firstAttributeError; | 1012 throw firstAttributeError; |
1011 } else { | 1013 } |
1012 return null; | 1014 return null; |
1013 } | |
1014 } | 1015 } |
1015 | 1016 |
1016 public void __setattr__(String name,PyObject value) { | 1017 public void __setattr__(String name,PyObject value) { |
1017 PyType self_type=getType(); | 1018 PyType self_type=getType(); |
1018 PyObject impl=self_type.lookup("__setattr__"); | 1019 PyObject impl=self_type.lookup("__setattr__"); |
1019 if (impl!=null) { | 1020 if (impl!=null) { |
1020 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); | 1021 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); |
1021 return; | 1022 return; |
1022 } | 1023 } |
1023 super.__setattr__(name,value); | 1024 super.__setattr__(name,value); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 if (impl!=null) | 1125 if (impl!=null) |
1125 return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava
__(Object.class); | 1126 return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava
__(Object.class); |
1126 return super.__tojava__(c); | 1127 return super.__tojava__(c); |
1127 } | 1128 } |
1128 | 1129 |
1129 public Object __coerce_ex__(PyObject o) { | 1130 public Object __coerce_ex__(PyObject o) { |
1130 PyType self_type=getType(); | 1131 PyType self_type=getType(); |
1131 PyObject impl=self_type.lookup("__coerce__"); | 1132 PyObject impl=self_type.lookup("__coerce__"); |
1132 if (impl!=null) { | 1133 if (impl!=null) { |
1133 PyObject res=impl.__get__(this,self_type).__call__(o); | 1134 PyObject res=impl.__get__(this,self_type).__call__(o); |
1134 if (res==null||res==Py.None) | 1135 if (res==Py.NotImplemented) |
1135 return res; | 1136 return Py.None; |
1136 if (!(res instanceof PyTuple)) | 1137 if (!(res instanceof PyTuple)) |
1137 throw Py.TypeError("coercion should return None or 2-tuple"); | 1138 throw Py.TypeError("__coerce__ didn't return a 2-tuple"); |
1138 return((PyTuple)res).getArray(); | 1139 return((PyTuple)res).getArray(); |
1139 } | 1140 } |
1140 return super.__coerce_ex__(o); | 1141 return super.__coerce_ex__(o); |
1141 } | 1142 } |
1142 | 1143 |
1143 public String toString() { | 1144 public String toString() { |
1144 PyType self_type=getType(); | 1145 PyType self_type=getType(); |
1145 PyObject impl=self_type.lookup("__repr__"); | 1146 PyObject impl=self_type.lookup("__repr__"); |
1146 if (impl!=null) { | 1147 if (impl!=null) { |
1147 PyObject res=impl.__get__(this,self_type).__call__(); | 1148 PyObject res=impl.__get__(this,self_type).__call__(); |
1148 if (!(res instanceof PyString)) | 1149 if (!(res instanceof PyString)) |
1149 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()+")"); |
1150 return((PyString)res).toString(); | 1151 return((PyString)res).toString(); |
1151 } | 1152 } |
1152 return super.toString(); | 1153 return super.toString(); |
1153 } | 1154 } |
1154 | 1155 |
1155 } | 1156 } |
LEFT | RIGHT |