KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.python.core;
2
3 public class PyListDerived extends PyList {
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 PyListDerived(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||self_type.lookup("__cmp__")!=null)
682             throw Py.TypeError("unhashable type");
683         return super.hashCode();
684     }
685
686     public int __cmp__(PyObject other) {
687         PyType self_type=getType();
688         PyObject impl=self_type.lookup("__cmp__");
689         if (impl!=null) {
690             PyObject res=impl.__get__(this,self_type).__call__(other);
691             if (res instanceof PyInteger) {
692                 int v=((PyInteger)res).getValue();
693                 return v<0?-1:v>0?1:0;
694             }
695             throw Py.TypeError("__cmp__ should return a int");
696         }
697         return super.__cmp__(other);
698     }
699
700     public boolean __nonzero__() {
701         PyType self_type=getType();
702         PyObject impl=self_type.lookup("__nonzero__");
703         if (impl==null) {
704             impl=self_type.lookup("__len__");
705             if (impl==null)
706                 return super.__nonzero__();
707         }
708         return impl.__get__(this,self_type).__call__().__nonzero__();
709     }
710
711     public boolean __contains__(PyObject o) {
712         PyType self_type=getType();
713         PyObject impl=self_type.lookup("__contains__");
714         if (impl==null)
715             return super.__contains__(o);
716         return impl.__get__(this,self_type).__call__(o).__nonzero__();
717     }
718
719     public int __len__() {
720         PyType self_type=getType();
721         PyObject impl=self_type.lookup("__len__");
722         if (impl!=null) {
723             PyObject res=impl.__get__(this,self_type).__call__();
724             if (res instanceof PyInteger)
725                 return((PyInteger)res).getValue();
726             throw Py.TypeError("__len__ should return a int");
727         }
728         return super.__len__();
729     }
730
731     public PyObject __iter__() {
732         PyType self_type=getType();
733         PyObject impl=self_type.lookup("__iter__");
734         if (impl!=null)
735             return impl.__get__(this,self_type).__call__();
736         impl=self_type.lookup("__getitem__");
737         if (impl==null)
738             return super.__iter__();
739         return new PySequenceIter(this);
740     }
741
742     public PyObject __iternext__() {
743         PyType self_type=getType();
744         PyObject impl=self_type.lookup("next");
745         if (impl!=null) {
746             try {
747                 return impl.__get__(this,self_type).__call__();
748             } catch (PyException exc) {
749                 if (Py.matchException(exc,Py.StopIteration))
750                     return null;
751                 throw exc;
752             }
753         }
754         return super.__iternext__(); // ???
755
}
756
757     public PyObject __finditem__(PyObject key) { // ???
758
PyType self_type=getType();
759         PyObject impl=self_type.lookup("__getitem__");
760         if (impl!=null)
761             try {
762                 return impl.__get__(this,self_type).__call__(key);
763             } catch (PyException exc) {
764                 if (Py.matchException(exc,Py.LookupError))
765                     return null;
766                 throw exc;
767             }
768         return super.__finditem__(key);
769     }
770
771     public void __setitem__(PyObject key,PyObject value) { // ???
772
PyType self_type=getType();
773         PyObject impl=self_type.lookup("__setitem__");
774         if (impl!=null) {
775             impl.__get__(this,self_type).__call__(key,value);
776             return;
777         }
778         super.__setitem__(key,value);
779     }
780
781     public void __delitem__(PyObject key) { // ???
782
PyType self_type=getType();
783         PyObject impl=self_type.lookup("__delitem__");
784         if (impl!=null) {
785             impl.__get__(this,self_type).__call__(key);
786             return;
787         }
788         super.__delitem__(key);
789     }
790
791     public PyObject __call__(PyObject args[],String JavaDoc keywords[]) {
792         ThreadState ts=Py.getThreadState();
793         if (ts.recursion_depth++>ts.systemState.getrecursionlimit())
794             throw Py.RuntimeError("maximum __call__ recursion depth exceeded");
795         try {
796             PyType self_type=getType();
797             PyObject impl=self_type.lookup("__call__");
798             if (impl!=null)
799                 return impl.__get__(this,self_type).__call__(args,keywords);
800             return super.__call__(args,keywords);
801         } finally {
802             --ts.recursion_depth;
803         }
804     }
805
806     public PyObject __findattr__(String JavaDoc name) {
807         PyType self_type=getType();
808         PyObject getattribute=self_type.lookup("__getattribute__");
809         PyString py_name=null;
810         try {
811             if (getattribute!=null) {
812                 return getattribute.__get__(this,self_type).__call__(py_name=new PyString(name));
813             } else {
814                 return super.__findattr__(name);
815             }
816         } catch (PyException e) {
817             if (Py.matchException(e,Py.AttributeError)) {
818                 PyObject getattr=self_type.lookup("__getattr__");
819                 if (getattr!=null)
820                     try {
821                         return getattr.__get__(this,self_type).__call__(py_name!=null?py_name:new PyString(name));
822                     } catch (PyException e1) {
823                         if (!Py.matchException(e1,Py.AttributeError))
824                             throw e1;
825                     }
826                 return null;
827             }
828             throw e;
829         }
830     }
831
832     public void __setattr__(String JavaDoc name,PyObject value) {
833         PyType self_type=getType();
834         PyObject impl=self_type.lookup("__setattr__");
835         if (impl!=null) {
836             impl.__get__(this,self_type).__call__(new PyString(name),value);
837             return;
838         }
839         super.__setattr__(name,value);
840     }
841
842     public void __delattr__(String JavaDoc name) {
843         PyType self_type=getType();
844         PyObject impl=self_type.lookup("__delattr__");
845         if (impl!=null) {
846             impl.__get__(this,self_type).__call__(new PyString(name));
847             return;
848         }
849         super.__delattr__(name);
850     }
851
852     public PyObject __get__(PyObject obj,PyObject type) {
853         PyType self_type=getType();
854         PyObject impl=self_type.lookup("__get__");
855         if (impl!=null) {
856             if (obj==null)
857                 obj=Py.None;
858             if (type==null)
859                 type=Py.None;
860             return impl.__get__(this,self_type).__call__(obj,type);
861         }
862         return super.__get__(obj,type);
863     }
864
865     public void __set__(PyObject obj,PyObject value) {
866         PyType self_type=getType();
867         PyObject impl=self_type.lookup("__set__");
868         if (impl!=null) {
869             impl.__get__(this,self_type).__call__(obj,value);
870             return;
871         }
872         super.__set__(obj,value);
873     }
874
875     public void __delete__(PyObject obj) {
876         PyType self_type=getType();
877         PyObject impl=self_type.lookup("__delete__");
878         if (impl!=null) {
879             impl.__get__(this,self_type).__call__(obj);
880             return;
881         }
882         super.__delete__(obj);
883     }
884
885     public void dispatch__init__(PyType type,PyObject[]args,String JavaDoc[]keywords) {
886         PyType self_type=getType();
887         if (self_type.isSubType(type)) {
888             PyObject impl=self_type.lookup("__init__");
889             if (impl!=null)
890                 impl.__get__(this,self_type).__call__(args,keywords);
891         }
892     }
893
894 }
895
Popular Tags