KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyDictionaryDerived


1 package org.python.core;
2
3 public class PyDictionaryDerived extends PyDictionary {
4
5     private PyObject dict;
6
7     public PyObject fastGetDict() {
8         return dict;
9     }
10
11     public PyObject getDict() {
12         return dict;
13     }
14
15     public PyDictionaryDerived(PyType subtype) {
16         super(subtype);
17         dict = subtype.instDict();
18     }
19
20     public PyString __str__() {
21         PyType self_type = getType();
22         PyObject impl = self_type.lookup("__str__");
23         if (impl != null) {
24             PyObject res = impl.__get__(this, self_type).__call__();
25             if (res instanceof PyString)
26                 return (PyString) res;
27             throw Py.TypeError("__str__" + " should return a " + "string");
28         }
29         return super.__str__();
30     }
31
32     public PyString __repr__() {
33         PyType self_type = getType();
34         PyObject impl = self_type.lookup("__repr__");
35         if (impl != null) {
36             PyObject res = impl.__get__(this, self_type).__call__();
37             if (res instanceof PyString)
38                 return (PyString) res;
39             throw Py.TypeError("__repr__" + " should return a " + "string");
40         }
41         return super.__repr__();
42     }
43
44     public PyString __hex__() {
45         PyType self_type = getType();
46         PyObject impl = self_type.lookup("__hex__");
47         if (impl != null) {
48             PyObject res = impl.__get__(this, self_type).__call__();
49             if (res instanceof PyString)
50                 return (PyString) res;
51             throw Py.TypeError("__hex__" + " should return a " + "string");
52         }
53         return super.__hex__();
54     }
55
56     public PyString __oct__() {
57         PyType self_type = getType();
58         PyObject impl = self_type.lookup("__oct__");
59         if (impl != null) {
60             PyObject res = impl.__get__(this, self_type).__call__();
61             if (res instanceof PyString)
62                 return (PyString) res;
63             throw Py.TypeError("__oct__" + " should return a " + "string");
64         }
65         return super.__oct__();
66     }
67
68     public PyObject __int__() {
69         PyType self_type = getType();
70         PyObject impl = self_type.lookup("__int__");
71         if (impl != null) {
72             PyObject res = impl.__get__(this, self_type).__call__();
73             if (res instanceof PyInteger)
74                 return (PyInteger) res;
75             throw Py.TypeError("__int__" + " should return a " + "int");
76         }
77         return super.__int__();
78     }
79
80     public PyFloat __float__() {
81         PyType self_type = getType();
82         PyObject impl = self_type.lookup("__float__");
83         if (impl != null) {
84             PyObject res = impl.__get__(this, self_type).__call__();
85             if (res instanceof PyFloat)
86                 return (PyFloat) res;
87             throw Py.TypeError("__float__" + " should return a " + "float");
88         }
89         return super.__float__();
90     }
91
92     public PyLong __long__() {
93         PyType self_type = getType();
94         PyObject impl = self_type.lookup("__long__");
95         if (impl != null) {
96             PyObject res = impl.__get__(this, self_type).__call__();
97             if (res instanceof PyLong)
98                 return (PyLong) res;
99             throw Py.TypeError("__long__" + " should return a " + "long");
100         }
101         return super.__long__();
102     }
103
104     public PyComplex __complex__() {
105         PyType self_type = getType();
106         PyObject impl = self_type.lookup("__complex__");
107         if (impl != null) {
108             PyObject res = impl.__get__(this, self_type).__call__();
109             if (res instanceof PyComplex)
110                 return (PyComplex) res;
111             throw Py.TypeError("__complex__" + " should return a " + "complex");
112         }
113         return super.__complex__();
114     }
115
116     public PyObject __pos__() {
117         PyType self_type = getType();
118         PyObject impl = self_type.lookup("__pos__");
119         if (impl != null)
120             return impl.__get__(this, self_type).__call__();
121         return super.__pos__();
122     }
123
124     public PyObject __neg__() {
125         PyType self_type = getType();
126         PyObject impl = self_type.lookup("__neg__");
127         if (impl != null)
128             return impl.__get__(this, self_type).__call__();
129         return super.__neg__();
130     }
131
132     public PyObject __abs__() {
133         PyType self_type = getType();
134         PyObject impl = self_type.lookup("__abs__");
135         if (impl != null)
136             return impl.__get__(this, self_type).__call__();
137         return super.__abs__();
138     }
139
140     public PyObject __invert__() {
141         PyType self_type = getType();
142         PyObject impl = self_type.lookup("__invert__");
143         if (impl != null)
144             return impl.__get__(this, self_type).__call__();
145         return super.__invert__();
146     }
147
148     public PyObject __add__(PyObject other) {
149         PyType self_type = getType();
150         PyObject impl = self_type.lookup("__add__");
151         if (impl != null) {
152             PyObject res = impl.__get__(this, self_type).__call__(other);
153             if (res == Py.NotImplemented)
154                 return null;
155             return res;
156         }
157         return super.__add__(other);
158     }
159
160     public PyObject __radd__(PyObject other) {
161         PyType self_type = getType();
162         PyObject impl = self_type.lookup("__radd__");
163         if (impl != null) {
164             PyObject res = impl.__get__(this, self_type).__call__(other);
165             if (res == Py.NotImplemented)
166                 return null;
167             return res;
168         }
169         return super.__radd__(other);
170     }
171
172     public PyObject __sub__(PyObject other) {
173         PyType self_type = getType();
174         PyObject impl = self_type.lookup("__sub__");
175         if (impl != null) {
176             PyObject res = impl.__get__(this, self_type).__call__(other);
177             if (res == Py.NotImplemented)
178                 return null;
179             return res;
180         }
181         return super.__sub__(other);
182     }
183
184     public PyObject __rsub__(PyObject other) {
185         PyType self_type = getType();
186         PyObject impl = self_type.lookup("__rsub__");
187         if (impl != null) {
188             PyObject res = impl.__get__(this, self_type).__call__(other);
189             if (res == Py.NotImplemented)
190                 return null;
191             return res;
192         }
193         return super.__rsub__(other);
194     }
195
196     public PyObject __mul__(PyObject other) {
197         PyType self_type = getType();
198         PyObject impl = self_type.lookup("__mul__");
199         if (impl != null) {
200             PyObject res = impl.__get__(this, self_type).__call__(other);
201             if (res == Py.NotImplemented)
202                 return null;
203             return res;
204         }
205         return super.__mul__(other);
206     }
207
208     public PyObject __rmul__(PyObject other) {
209         PyType self_type = getType();
210         PyObject impl = self_type.lookup("__rmul__");
211         if (impl != null) {
212             PyObject res = impl.__get__(this, self_type).__call__(other);
213             if (res == Py.NotImplemented)
214                 return null;
215             return res;
216         }
217         return super.__rmul__(other);
218     }
219
220     public PyObject __div__(PyObject other) {
221         PyType self_type = getType();
222         PyObject impl = self_type.lookup("__div__");
223         if (impl != null) {
224             PyObject res = impl.__get__(this, self_type).__call__(other);
225             if (res == Py.NotImplemented)
226                 return null;
227             return res;
228         }
229         return super.__div__(other);
230     }
231
232     public PyObject __rdiv__(PyObject other) {
233         PyType self_type = getType();
234         PyObject impl = self_type.lookup("__rdiv__");
235         if (impl != null) {
236             PyObject res = impl.__get__(this, self_type).__call__(other);
237             if (res == Py.NotImplemented)
238                 return null;
239             return res;
240         }
241         return super.__rdiv__(other);
242     }
243
244     public PyObject __floordiv__(PyObject other) {
245         PyType self_type = getType();
246         PyObject impl = self_type.lookup("__floordiv__");
247         if (impl != null) {
248             PyObject res = impl.__get__(this, self_type).__call__(other);
249             if (res == Py.NotImplemented)
250                 return null;
251             return res;
252         }
253         return super.__floordiv__(other);
254     }
255
256     public PyObject __rfloordiv__(PyObject other) {
257         PyType self_type = getType();
258         PyObject impl = self_type.lookup("__rfloordiv__");
259         if (impl != null) {
260             PyObject res = impl.__get__(this, self_type).__call__(other);
261             if (res == Py.NotImplemented)
262                 return null;
263             return res;
264         }
265         return super.__rfloordiv__(other);
266     }
267
268     public PyObject __truediv__(PyObject other) {
269         PyType self_type = getType();
270         PyObject impl = self_type.lookup("__truediv__");
271         if (impl != null) {
272             PyObject res = impl.__get__(this, self_type).__call__(other);
273             if (res == Py.NotImplemented)
274                 return null;
275             return res;
276         }
277         return super.__truediv__(other);
278     }
279
280     public PyObject __rtruediv__(PyObject other) {
281         PyType self_type = getType();
282         PyObject impl = self_type.lookup("__rtruediv__");
283         if (impl != null) {
284             PyObject res = impl.__get__(this, self_type).__call__(other);
285             if (res == Py.NotImplemented)
286                 return null;
287             return res;
288         }
289         return super.__rtruediv__(other);
290     }
291
292     public PyObject __mod__(PyObject other) {
293         PyType self_type = getType();
294         PyObject impl = self_type.lookup("__mod__");
295         if (impl != null) {
296             PyObject res = impl.__get__(this, self_type).__call__(other);
297             if (res == Py.NotImplemented)
298                 return null;
299             return res;
300         }
301         return super.__mod__(other);
302     }
303
304     public PyObject __rmod__(PyObject other) {
305         PyType self_type = getType();
306         PyObject impl = self_type.lookup("__rmod__");
307         if (impl != null) {
308             PyObject res = impl.__get__(this, self_type).__call__(other);
309             if (res == Py.NotImplemented)
310                 return null;
311             return res;
312         }
313         return super.__rmod__(other);
314     }
315
316     public PyObject __divmod__(PyObject other) {
317         PyType self_type = getType();
318         PyObject impl = self_type.lookup("__divmod__");
319         if (impl != null) {
320             PyObject res = impl.__get__(this, self_type).__call__(other);
321             if (res == Py.NotImplemented)
322                 return null;
323             return res;
324         }
325         return super.__divmod__(other);
326     }
327
328     public PyObject __rdivmod__(PyObject other) {
329         PyType self_type = getType();
330         PyObject impl = self_type.lookup("__rdivmod__");
331         if (impl != null) {
332             PyObject res = impl.__get__(this, self_type).__call__(other);
333             if (res == Py.NotImplemented)
334                 return null;
335             return res;
336         }
337         return super.__rdivmod__(other);
338     }
339
340     public PyObject __pow__(PyObject other) {
341         PyType self_type = getType();
342         PyObject impl = self_type.lookup("__pow__");
343         if (impl != null) {
344             PyObject res = impl.__get__(this, self_type).__call__(other);
345             if (res == Py.NotImplemented)
346                 return null;
347             return res;
348         }
349         return super.__pow__(other);
350     }
351
352     public PyObject __rpow__(PyObject other) {
353         PyType self_type = getType();
354         PyObject impl = self_type.lookup("__rpow__");
355         if (impl != null) {
356             PyObject res = impl.__get__(this, self_type).__call__(other);
357             if (res == Py.NotImplemented)
358                 return null;
359             return res;
360         }
361         return super.__rpow__(other);
362     }
363
364     public PyObject __lshift__(PyObject other) {
365         PyType self_type = getType();
366         PyObject impl = self_type.lookup("__lshift__");
367         if (impl != null) {
368             PyObject res = impl.__get__(this, self_type).__call__(other);
369             if (res == Py.NotImplemented)
370                 return null;
371             return res;
372         }
373         return super.__lshift__(other);
374     }
375
376     public PyObject __rlshift__(PyObject other) {
377         PyType self_type = getType();
378         PyObject impl = self_type.lookup("__rlshift__");
379         if (impl != null) {
380             PyObject res = impl.__get__(this, self_type).__call__(other);
381             if (res == Py.NotImplemented)
382                 return null;
383             return res;
384         }
385         return super.__rlshift__(other);
386     }
387
388     public PyObject __rshift__(PyObject other) {
389         PyType self_type = getType();
390         PyObject impl = self_type.lookup("__rshift__");
391         if (impl != null) {
392             PyObject res = impl.__get__(this, self_type).__call__(other);
393             if (res == Py.NotImplemented)
394                 return null;
395             return res;
396         }
397         return super.__rshift__(other);
398     }
399
400     public PyObject __rrshift__(PyObject other) {
401         PyType self_type = getType();
402         PyObject impl = self_type.lookup("__rrshift__");
403         if (impl != null) {
404             PyObject res = impl.__get__(this, self_type).__call__(other);
405             if (res == Py.NotImplemented)
406                 return null;
407             return res;
408         }
409         return super.__rrshift__(other);
410     }
411
412     public PyObject __and__(PyObject other) {
413         PyType self_type = getType();
414         PyObject impl = self_type.lookup("__and__");
415         if (impl != null) {
416             PyObject res = impl.__get__(this, self_type).__call__(other);
417             if (res == Py.NotImplemented)
418                 return null;
419             return res;
420         }
421         return super.__and__(other);
422     }
423
424     public PyObject __rand__(PyObject other) {
425         PyType self_type = getType();
426         PyObject impl = self_type.lookup("__rand__");
427         if (impl != null) {
428             PyObject res = impl.__get__(this, self_type).__call__(other);
429             if (res == Py.NotImplemented)
430                 return null;
431             return res;
432         }
433         return super.__rand__(other);
434     }
435
436     public PyObject __or__(PyObject other) {
437         PyType self_type = getType();
438         PyObject impl = self_type.lookup("__or__");
439         if (impl != null) {
440             PyObject res = impl.__get__(this, self_type).__call__(other);
441             if (res == Py.NotImplemented)
442                 return null;
443             return res;
444         }
445         return super.__or__(other);
446     }
447
448     public PyObject __ror__(PyObject other) {
449         PyType self_type = getType();
450         PyObject impl = self_type.lookup("__ror__");
451         if (impl != null) {
452             PyObject res = impl.__get__(this, self_type).__call__(other);
453             if (res == Py.NotImplemented)
454                 return null;
455             return res;
456         }
457         return super.__ror__(other);
458     }
459
460     public PyObject __xor__(PyObject other) {
461         PyType self_type = getType();
462         PyObject impl = self_type.lookup("__xor__");
463         if (impl != null) {
464             PyObject res = impl.__get__(this, self_type).__call__(other);
465             if (res == Py.NotImplemented)
466                 return null;
467             return res;
468         }
469         return super.__xor__(other);
470     }
471
472     public PyObject __rxor__(PyObject other) {
473         PyType self_type = getType();
474         PyObject impl = self_type.lookup("__rxor__");
475         if (impl != null) {
476             PyObject res = impl.__get__(this, self_type).__call__(other);
477             if (res == Py.NotImplemented)
478                 return null;
479             return res;
480         }
481         return super.__rxor__(other);
482     }
483
484     public PyObject __lt__(PyObject other) {
485         PyType self_type = getType();
486         PyObject impl = self_type.lookup("__lt__");
487         if (impl != null) {
488             PyObject res = impl.__get__(this, self_type).__call__(other);
489             if (res == Py.NotImplemented)
490                 return null;
491             return res;
492         }
493         return super.__lt__(other);
494     }
495
496     public PyObject __le__(PyObject other) {
497         PyType self_type = getType();
498         PyObject impl = self_type.lookup("__le__");
499         if (impl != null) {
500             PyObject res = impl.__get__(this, self_type).__call__(other);
501             if (res == Py.NotImplemented)
502                 return null;
503             return res;
504         }
505         return super.__le__(other);
506     }
507
508     public PyObject __gt__(PyObject other) {
509         PyType self_type = getType();
510         PyObject impl = self_type.lookup("__gt__");
511         if (impl != null) {
512             PyObject res = impl.__get__(this, self_type).__call__(other);
513             if (res == Py.NotImplemented)
514                 return null;
515             return res;
516         }
517         return super.__gt__(other);
518     }
519
520     public PyObject __ge__(PyObject other) {
521         PyType self_type = getType();
522         PyObject impl = self_type.lookup("__ge__");
523         if (impl != null) {
524             PyObject res = impl.__get__(this, self_type).__call__(other);
525             if (res == Py.NotImplemented)
526                 return null;
527             return res;
528         }
529         return super.__ge__(other);
530     }
531
532     public PyObject __eq__(PyObject other) {
533         PyType self_type = getType();
534         PyObject impl = self_type.lookup("__eq__");
535         if (impl != null) {
536             PyObject res = impl.__get__(this, self_type).__call__(other);
537             if (res == Py.NotImplemented)
538                 return null;
539             return res;
540         }
541         return super.__eq__(other);
542     }
543
544     public PyObject __ne__(PyObject other) {
545         PyType self_type = getType();
546         PyObject impl = self_type.lookup("__ne__");
547         if (impl != null) {
548             PyObject res = impl.__get__(this, self_type).__call__(other);
549             if (res == Py.NotImplemented)
550                 return null;
551             return res;
552         }
553         return super.__ne__(other);
554     }
555
556     public PyObject __iadd__(PyObject other) {
557         PyType self_type = getType();
558         PyObject impl = self_type.lookup("__iadd__");
559         if (impl != null)
560             return impl.__get__(this, self_type).__call__(other);
561         return super.__iadd__(other);
562     }
563
564     public PyObject __isub__(PyObject other) {
565         PyType self_type = getType();
566         PyObject impl = self_type.lookup("__isub__");
567         if (impl != null)
568             return impl.__get__(this, self_type).__call__(other);
569         return super.__isub__(other);
570     }
571
572     public PyObject __imul__(PyObject other) {
573         PyType self_type = getType();
574         PyObject impl = self_type.lookup("__imul__");
575         if (impl != null)
576             return impl.__get__(this, self_type).__call__(other);
577         return super.__imul__(other);
578     }
579
580     public PyObject __idiv__(PyObject other) {
581         PyType self_type = getType();
582         PyObject impl = self_type.lookup("__idiv__");
583         if (impl != null)
584             return impl.__get__(this, self_type).__call__(other);
585         return super.__idiv__(other);
586     }
587
588     public PyObject __ifloordiv__(PyObject other) {
589         PyType self_type = getType();
590         PyObject impl = self_type.lookup("__ifloordiv__");
591         if (impl != null)
592             return impl.__get__(this, self_type).__call__(other);
593         return super.__ifloordiv__(other);
594     }
595
596     public PyObject __itruediv__(PyObject other) {
597         PyType self_type = getType();
598         PyObject impl = self_type.lookup("__itruediv__");
599         if (impl != null)
600             return impl.__get__(this, self_type).__call__(other);
601         return super.__itruediv__(other);
602     }
603
604     public PyObject __imod__(PyObject other) {
605         PyType self_type = getType();
606         PyObject impl = self_type.lookup("__imod__");
607         if (impl != null)
608             return impl.__get__(this, self_type).__call__(other);
609         return super.__imod__(other);
610     }
611
612     public PyObject __ipow__(PyObject other) {
613         PyType self_type = getType();
614         PyObject impl = self_type.lookup("__ipow__");
615         if (impl != null)
616             return impl.__get__(this, self_type).__call__(other);
617         return super.__ipow__(other);
618     }
619
620     public PyObject __ilshift__(PyObject other) {
621         PyType self_type = getType();
622         PyObject impl = self_type.lookup("__ilshift__");
623         if (impl != null)
624             return impl.__get__(this, self_type).__call__(other);
625         return super.__ilshift__(other);
626     }
627
628     public PyObject __irshift__(PyObject other) {
629         PyType self_type = getType();
630         PyObject impl = self_type.lookup("__irshift__");
631         if (impl != null)
632             return impl.__get__(this, self_type).__call__(other);
633         return super.__irshift__(other);
634     }
635
636     public PyObject __iand__(PyObject other) {
637         PyType self_type = getType();
638         PyObject impl = self_type.lookup("__iand__");
639         if (impl != null)
640             return impl.__get__(this, self_type).__call__(other);
641         return super.__iand__(other);
642     }
643
644     public PyObject __ior__(PyObject other) {
645         PyType self_type = getType();
646         PyObject impl = self_type.lookup("__ior__");
647         if (impl != null)
648             return impl.__get__(this, self_type).__call__(other);
649         return super.__ior__(other);
650     }
651
652     public PyObject __ixor__(PyObject other) {
653         PyType self_type = getType();
654         PyObject impl = self_type.lookup("__ixor__");
655         if (impl != null)
656             return impl.__get__(this, self_type).__call__(other);
657         return super.__ixor__(other);
658     }
659
660     public String JavaDoc toString() {
661         PyType self_type = getType();
662         PyObject impl = self_type.lookup("__repr__");
663         if (impl != null) {
664             PyObject res = impl.__get__(this, self_type).__call__();
665             if (!(res instanceof PyString))
666                 throw Py.TypeError("__repr__ should return a string");
667             return ((PyString) res).toString();
668         }
669         return super.toString();
670     }
671
672     public int hashCode() {
673         PyType self_type = getType();
674         PyObject impl = self_type.lookup("__hash__");
675         if (impl != null) {
676             PyObject res = impl.__get__(this, self_type).__call__();
677             if (res instanceof PyInteger)
678                 return ((PyInteger) res).getValue();
679             throw Py.TypeError("__hash__ should return a int");
680         }
681         if (self_type.lookup("__eq__") != null
682                 || self_type.lookup("__cmp__") != null)
683             throw Py.TypeError("unhashable type");
684         return super.hashCode();
685     }
686
687     public int __cmp__(PyObject other) {
688         PyType self_type = getType();
689         PyObject impl = self_type.lookup("__cmp__");
690         if (impl != null) {
691             PyObject res = impl.__get__(this, self_type).__call__(other);
692             if (res instanceof PyInteger) {
693                 int v = ((PyInteger) res).getValue();
694                 return v < 0 ? -1 : v > 0 ? 1 : 0;
695             }
696             throw Py.TypeError("__cmp__ should return a int");
697         }
698         return super.__cmp__(other);
699     }
700
701     public boolean __nonzero__() {
702         PyType self_type = getType();
703         PyObject impl = self_type.lookup("__nonzero__");
704         if (impl == null) {
705             impl = self_type.lookup("__len__");
706             if (impl == null)
707                 return super.__nonzero__();
708         }
709         return impl.__get__(this, self_type).__call__().__nonzero__();
710     }
711
712     public boolean __contains__(PyObject o) {
713         PyType self_type = getType();
714         PyObject impl = self_type.lookup("__contains__");
715         if (impl == null)
716             return super.__contains__(o);
717         return impl.__get__(this, self_type).__call__(o).__nonzero__();
718     }
719
720     public int __len__() {
721         PyType self_type = getType();
722         PyObject impl = self_type.lookup("__len__");
723         if (impl != null) {
724             PyObject res = impl.__get__(this, self_type).__call__();
725             if (res instanceof PyInteger)
726                 return ((PyInteger) res).getValue();
727             throw Py.TypeError("__len__ should return a int");
728         }
729         return super.__len__();
730     }
731
732     public PyObject __iter__() {
733         PyType self_type = getType();
734         PyObject impl = self_type.lookup("__iter__");
735         if (impl != null)
736             return impl.__get__(this, self_type).__call__();
737         impl = self_type.lookup("__getitem__");
738         if (impl == null)
739             return super.__iter__();
740         return new PySequenceIter(this);
741     }
742
743     public PyObject __iternext__() {
744         PyType self_type = getType();
745         PyObject impl = self_type.lookup("next");
746         if (impl != null) {
747             try {
748                 return impl.__get__(this, self_type).__call__();
749             } catch (PyException exc) {
750                 if (Py.matchException(exc, Py.StopIteration))
751                     return null;
752                 throw exc;
753             }
754         }
755         return super.__iternext__(); // ???
756
}
757
758     public PyObject __finditem__(PyObject key) { // ???
759
PyType self_type = getType();
760         PyObject impl = self_type.lookup("__getitem__");
761         if (impl != null)
762             try {
763                 return impl.__get__(this, self_type).__call__(key);
764             } catch (PyException exc) {
765                 if (Py.matchException(exc, Py.LookupError))
766                     return null;
767                 throw exc;
768             }
769         return super.__finditem__(key);
770     }
771
772     public void __setitem__(PyObject key, PyObject value) { // ???
773
PyType self_type = getType();
774         PyObject impl = self_type.lookup("__setitem__");
775         if (impl != null) {
776             impl.__get__(this, self_type).__call__(key, value);
777             return;
778         }
779         super.__setitem__(key, value);
780     }
781
782     public void __delitem__(PyObject key) { // ???
783
PyType self_type = getType();
784         PyObject impl = self_type.lookup("__delitem__");
785         if (impl != null) {
786             impl.__get__(this, self_type).__call__(key);
787             return;
788         }
789         super.__delitem__(key);
790     }
791
792     public PyObject __call__(PyObject args[], String JavaDoc keywords[]) {
793         ThreadState ts = Py.getThreadState();
794         if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())
795             throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
796         try {
797             PyType self_type = getType();
798             PyObject impl = self_type.lookup("__call__");
799             if (impl != null)
800                 return impl.__get__(this, self_type).__call__(args, keywords);
801             return super.__call__(args, keywords);
802         } finally {
803             --ts.recursion_depth;
804         }
805     }
806
807     public PyObject __findattr__(String JavaDoc name) {
808         PyType self_type = getType();
809         PyObject getattribute = self_type.lookup("__getattribute__");
810         PyString py_name = null;
811         try {
812             if (getattribute != null) {
813                 return getattribute.__get__(this, self_type).__call__(
814                         py_name = new PyString(name));
815             } else {
816                 return super.__findattr__(name);
817             }
818         } catch (PyException e) {
819             if (Py.matchException(e, Py.AttributeError)) {
820                 PyObject getattr = self_type.lookup("__getattr__");
821                 if (getattr != null)
822                     try {
823                         return getattr.__get__(this, self_type).__call__(
824                                 py_name != null ? py_name : new PyString(name));
825                     } catch (PyException e1) {
826                         if (!Py.matchException(e1, Py.AttributeError))
827                             throw e1;
828                     }
829                 return null;
830             }
831             throw e;
832         }
833     }
834
835     public void __setattr__(String JavaDoc name, PyObject value) {
836         PyType self_type = getType();
837         PyObject impl = self_type.lookup("__setattr__");
838         if (impl != null) {
839             impl.__get__(this, self_type).__call__(new PyString(name), value);
840             return;
841         }
842         super.__setattr__(name, value);
843     }
844
845     public void __delattr__(String JavaDoc name) {
846         PyType self_type = getType();
847         PyObject impl = self_type.lookup("__delattr__");
848         if (impl != null) {
849             impl.__get__(this, self_type).__call__(new PyString(name));
850             return;
851         }
852         super.__delattr__(name);
853     }
854
855     public PyObject __get__(PyObject obj, PyObject type) {
856         PyType self_type = getType();
857         PyObject impl = self_type.lookup("__get__");
858         if (impl != null) {
859             if (obj == null)
860                 obj = Py.None;
861             if (type == null)
862                 type = Py.None;
863             return impl.__get__(this, self_type).__call__(obj, type);
864         }
865         return super.__get__(obj, type);
866     }
867
868     public void __set__(PyObject obj, PyObject value) {
869         PyType self_type = getType();
870         PyObject impl = self_type.lookup("__set__");
871         if (impl != null) {
872             impl.__get__(this, self_type).__call__(obj, value);
873             return;
874         }
875         super.__set__(obj, value);
876     }
877
878     public void __delete__(PyObject obj) {
879         PyType self_type = getType();
880         PyObject impl = self_type.lookup("__delete__");
881         if (impl != null) {
882             impl.__get__(this, self_type).__call__(obj);
883             return;
884         }
885         super.__delete__(obj);
886     }
887
888     public void dispatch__init__(PyType type, PyObject[] args, String JavaDoc[] keywords) {
889         PyType self_type = getType();
890         if (self_type.isSubType(type)) {
891             PyObject impl = self_type.lookup("__init__");
892             if (impl != null)
893                 impl.__get__(this, self_type).__call__(args, keywords);
894         }
895     }
896
897 }
898
Popular Tags