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.thread; | 2 package org.python.modules.thread; |
3 | 3 |
4 import org.python.core.*; | 4 import org.python.core.*; |
5 | 5 |
6 public class PyLocalDerived extends PyLocal implements Slotted { | 6 public class PyLocalDerived extends PyLocal 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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 if (impl!=null) | 945 if (impl!=null) |
946 return impl.__get__(this,self_type).__call__(args,keywords); | 946 return impl.__get__(this,self_type).__call__(args,keywords); |
947 return super.__call__(args,keywords); | 947 return super.__call__(args,keywords); |
948 } finally { | 948 } finally { |
949 --ts.recursion_depth; | 949 --ts.recursion_depth; |
950 } | 950 } |
951 } | 951 } |
952 | 952 |
953 public PyObject __findattr_ex__(String name) { | 953 public PyObject __findattr_ex__(String name) { |
954 PyType self_type=getType(); | 954 PyType self_type=getType(); |
| 955 // TODO: We should speed this up. As the __getattribute__ slot almost ne
ver |
| 956 // changes, it is a good candidate for caching, as PyClass does wi
th |
| 957 // __getattr__. See #1102. |
955 PyObject getattribute=self_type.lookup("__getattribute__"); | 958 PyObject getattribute=self_type.lookup("__getattribute__"); |
956 PyString py_name=null; | 959 PyString py_name=null; |
957 PyException firstAttributeError=null; | 960 PyException firstAttributeError=null; |
958 try { | 961 try { |
959 if (getattribute!=null) { | 962 if (getattribute!=null) { |
960 return getattribute.__get__(this,self_type).__call__(py_name=PyS
tring.fromInterned(name)); | 963 py_name=PyString.fromInterned(name); |
| 964 return getattribute.__get__(this,self_type).__call__(py_name); |
961 } else { | 965 } else { |
962 // XXX: This shouldn't happen, becase PyObject exposes | 966 Py.Warning(String.format("__getattribute__ not found on type %s"
,self_type.getName())); |
963 // __getattribute__.· | |
964 // | |
965 // And, by the way, invoking object__getattribute__ is the· | |
966 // common case. We should optimize that to avoid doing the | |
967 // '__getattribute__' lookup each time.· | |
968 PyObject ret=super.__findattr_ex__(name); | 967 PyObject ret=super.__findattr_ex__(name); |
969 if (ret!=null) { | 968 if (ret!=null) { |
970 return ret; | 969 return ret; |
971 } // else: pass through to __getitem__ invocation | 970 } // else: pass through to __getitem__ invocation |
972 } | 971 } |
973 } catch (PyException e) { | 972 } catch (PyException e) { |
974 if (!Py.matchException(e,Py.AttributeError)) { | 973 if (!Py.matchException(e,Py.AttributeError)) { |
975 throw e; | 974 throw e; |
976 } else { | 975 } else { |
977 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors | 976 firstAttributeError=e; // saved to avoid swallowing custom Attri
buteErrors |
978 // and pass through to __getattr__ invocation. | 977 // and pass through to __getattr__ invocation. |
979 } | 978 } |
980 } | 979 } |
981 PyObject getattr=self_type.lookup("__getattr__"); | 980 PyObject getattr=self_type.lookup("__getattr__"); |
982 if (getattr!=null) { | 981 if (getattr!=null) { |
983 return getattr.__get__(this,self_type).__call__(py_name!=null?py_nam
e:PyString.fromInterned(name)); | 982 if (py_name==null) { |
| 983 py_name=PyString.fromInterned(name); |
| 984 } |
| 985 return getattr.__get__(this,self_type).__call__(py_name); |
984 } | 986 } |
985 if (firstAttributeError!=null) { | 987 if (firstAttributeError!=null) { |
986 throw firstAttributeError; | 988 throw firstAttributeError; |
987 } else { | 989 } |
988 return null; | 990 return null; |
989 } | |
990 } | 991 } |
991 | 992 |
992 public void __setattr__(String name,PyObject value) { | 993 public void __setattr__(String name,PyObject value) { |
993 PyType self_type=getType(); | 994 PyType self_type=getType(); |
994 PyObject impl=self_type.lookup("__setattr__"); | 995 PyObject impl=self_type.lookup("__setattr__"); |
995 if (impl!=null) { | 996 if (impl!=null) { |
996 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); | 997 impl.__get__(this,self_type).__call__(PyString.fromInterned(name),va
lue); |
997 return; | 998 return; |
998 } | 999 } |
999 super.__setattr__(name,value); | 1000 super.__setattr__(name,value); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 if (impl!=null) | 1101 if (impl!=null) |
1101 return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava
__(Object.class); | 1102 return impl.__get__(this,self_type).__call__(Py.java2py(c)).__tojava
__(Object.class); |
1102 return super.__tojava__(c); | 1103 return super.__tojava__(c); |
1103 } | 1104 } |
1104 | 1105 |
1105 public Object __coerce_ex__(PyObject o) { | 1106 public Object __coerce_ex__(PyObject o) { |
1106 PyType self_type=getType(); | 1107 PyType self_type=getType(); |
1107 PyObject impl=self_type.lookup("__coerce__"); | 1108 PyObject impl=self_type.lookup("__coerce__"); |
1108 if (impl!=null) { | 1109 if (impl!=null) { |
1109 PyObject res=impl.__get__(this,self_type).__call__(o); | 1110 PyObject res=impl.__get__(this,self_type).__call__(o); |
1110 if (res==null||res==Py.None) | 1111 if (res==Py.NotImplemented) |
1111 return res; | 1112 return Py.None; |
1112 if (!(res instanceof PyTuple)) | 1113 if (!(res instanceof PyTuple)) |
1113 throw Py.TypeError("coercion should return None or 2-tuple"); | 1114 throw Py.TypeError("__coerce__ didn't return a 2-tuple"); |
1114 return((PyTuple)res).getArray(); | 1115 return((PyTuple)res).getArray(); |
1115 } | 1116 } |
1116 return super.__coerce_ex__(o); | 1117 return super.__coerce_ex__(o); |
1117 } | 1118 } |
1118 | 1119 |
1119 public String toString() { | 1120 public String toString() { |
1120 PyType self_type=getType(); | 1121 PyType self_type=getType(); |
1121 PyObject impl=self_type.lookup("__repr__"); | 1122 PyObject impl=self_type.lookup("__repr__"); |
1122 if (impl!=null) { | 1123 if (impl!=null) { |
1123 PyObject res=impl.__get__(this,self_type).__call__(); | 1124 PyObject res=impl.__get__(this,self_type).__call__(); |
1124 if (!(res instanceof PyString)) | 1125 if (!(res instanceof PyString)) |
1125 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); | 1126 throw Py.TypeError("__repr__ returned non-string (type "+res.get
Type().fastGetName()+")"); |
1126 return((PyString)res).toString(); | 1127 return((PyString)res).toString(); |
1127 } | 1128 } |
1128 return super.toString(); | 1129 return super.toString(); |
1129 } | 1130 } |
1130 | 1131 |
1131 } | 1132 } |
LEFT | RIGHT |