KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > modules > sets > PySetDerived


1 package org.python.modules.sets;
2
3 import org.python.core.PyObject;
4 import org.python.core.PyFloat;
5 import org.python.core.PyComplex;
6 import org.python.core.PyType;
7 import org.python.core.Py;
8 import org.python.core.PyString;
9 import org.python.core.PyException;
10 import org.python.core.PyLong;
11 import org.python.core.PyInteger;
12 import org.python.core.ThreadState;
13 import org.python.core.PySequenceIter;
14
15 public class PySetDerived extends PySet {
16
17     private PyObject dict;
18
19     public PyObject fastGetDict() {
20         return dict;
21     }
22
23     public PyObject getDict() {
24         return dict;
25     }
26
27     public PySetDerived(PyType subtype) {
28         super(subtype);
29         dict=subtype.instDict();
30     }
31
32     public PyString __str__() {
33         PyType self_type=getType();
34         PyObject impl=self_type.lookup("__str__");
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("__str__"+" should return a "+"string");
40         }
41         return super.__str__();
42     }
43
44     public PyString __repr__() {
45         PyType self_type=getType();
46         PyObject impl=self_type.lookup("__repr__");
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("__repr__"+" should return a "+"string");
52         }
53         return super.__repr__();
54     }
55
56     public PyString __hex__() {
57         PyType self_type=getType();
58         PyObject impl=self_type.lookup("__hex__");
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("__hex__"+" should return a "+"string");
64         }
65         return super.__hex__();
66     }
67
68     public PyString __oct__() {
69         PyType self_type=getType();
70         PyObject impl=self_type.lookup("__oct__");
71         if (impl!=null) {
72             PyObject res=impl.__get__(this,self_type).__call__();
73             if (res instanceof PyString)
74                 return(PyString)res;
75             throw Py.TypeError("__oct__"+" should return a "+"string");
76         }
77         return super.__oct__();
78     }
79
80     public PyObject __int__() {
81         PyType self_type=getType();
82         PyObject impl=self_type.lookup("__int__");
83         if (impl!=null) {
84             PyObject res=impl.__get__(this,self_type).__call__();
85             if (res instanceof PyInteger)
86                 return(PyInteger)res;
87             throw Py.TypeError("__int__"+" should return a "+"int");
88         }
89         return super.__int__();
90     }
91
92     public PyFloat __float__() {
93         PyType self_type=getType();
94         PyObject impl=self_type.lookup("__float__");
95         if (impl!=null) {
96             PyObject res=impl.__get__(this,self_type).__call__();
97             if (res instanceof PyFloat)
98                 return(PyFloat)res;
99             throw Py.TypeError("__float__"+" should return a "+"float");
100         }
101         return super.__float__();
102     }
103
104     public PyLong __long__() {
105         PyType self_type=getType();
106         PyObject impl=self_type.lookup("__long__");
107         if (impl!=null) {
108             PyObject res=impl.__get__(this,self_type).__call__();
109             if (res instanceof PyLong)
110                 return(PyLong)res;
111             throw Py.TypeError("__long__"+" should return a "+"long");
112         }
113         return super.__long__();
114     }
115
116     public PyComplex __complex__() {
117         PyType self_type=getType();
118         PyObject impl=self_type.lookup("__complex__");
119         if (impl!=null) {
120             PyObject res=impl.__get__(this,self_type).__call__();
121             if (res instanceof PyComplex)
122                 return(PyComplex)res;
123             throw Py.TypeError("__complex__"+" should return a "+"complex");
124         }
125         return super.__complex__();
126     }
127
128     public PyObject __pos__() {
129         PyType self_type=getType();
130         PyObject impl=self_type.lookup("__pos__");
131         if (impl!=null)
132             return impl.__get__(this,self_type).__call__();
133         return super.__pos__();
134     }
135
136     public PyObject __neg__() {
137         PyType self_type=getType();
138         PyObject impl=self_type.lookup("__neg__");
139         if (impl!=null)
140             return impl.__get__(this,self_type).__call__();
141         return super.__neg__();
142     }
143
144     public PyObject __abs__() {
145         PyType self_type=getType();
146         PyObject impl=self_type.lookup("__abs__");
147         if (impl!=null)
148             return impl.__get__(this,self_type).__call__();
149         return super.__abs__();
150     }
151
152     public PyObject __invert__() {
153         PyType self_type=getType();
154         PyObject impl=self_type.lookup("__invert__");
155         if (impl!=null)
156             return impl.__get__(this,self_type).__call__();
157         return super.__invert__();
158     }
159
160     public PyObject __add__(PyObject other) {
161         PyType self_type=getType();
162         PyObject impl=self_type.lookup("__add__");
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.__add__(other);
170     }
171
172     public PyObject __radd__(PyObject other) {
173         PyType self_type=getType();
174         PyObject impl=self_type.lookup("__radd__");
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.__radd__(other);
182     }
183
184     public PyObject __sub__(PyObject other) {
185         PyType self_type=getType();
186         PyObject impl=self_type.lookup("__sub__");
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.__sub__(other);
194     }
195
196     public PyObject __rsub__(PyObject other) {
197         PyType self_type=getType();
198         PyObject impl=self_type.lookup("__rsub__");
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.__rsub__(other);
206     }
207
208     public PyObject __mul__(PyObject other) {
209         PyType self_type=getType();
210         PyObject impl=self_type.lookup("__mul__");
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.__mul__(other);
218     }
219
220     public PyObject __rmul__(PyObject other) {
221         PyType self_type=getType();
222         PyObject impl=self_type.lookup("__rmul__");
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.__rmul__(other);
230     }
231
232     public PyObject __div__(PyObject other) {
233         PyType self_type=getType();
234         PyObject impl=self_type.lookup("__div__");
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.__div__(other);
242     }
243
244     public PyObject __rdiv__(PyObject other) {
245         PyType self_type=getType();
246         PyObject impl=self_type.lookup("__rdiv__");
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.__rdiv__(other);
254     }
255
256     public PyObject __floordiv__(PyObject other) {
257         PyType self_type=getType();
258         PyObject impl=self_type.lookup("__floordiv__");
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.__floordiv__(other);
266     }
267
268     public PyObject __rfloordiv__(PyObject other) {
269         PyType self_type=getType();
270         PyObject impl=self_type.lookup("__rfloordiv__");
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.__rfloordiv__(other);
278     }
279
280     public PyObject __truediv__(PyObject other) {
281         PyType self_type=getType();
282         PyObject impl=self_type.lookup("__truediv__");
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.__truediv__(other);
290     }
291
292     public PyObject __rtruediv__(PyObject other) {
293         PyType self_type=getType();
294         PyObject impl=self_type.lookup("__rtruediv__");
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.__rtruediv__(other);
302     }
303
304     public PyObject __mod__(PyObject other) {
305         PyType self_type=getType();
306         PyObject impl=self_type.lookup("__mod__");
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.__mod__(other);
314     }
315
316     public PyObject __rmod__(PyObject other) {
317         PyType self_type=getType();
318         PyObject impl=self_type.lookup("__rmod__");
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.__rmod__(other);
326     }
327
328     public PyObject __divmod__(PyObject other) {
329         PyType self_type=getType();
330         PyObject impl=self_type.lookup("__divmod__");
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.__divmod__(other);
338     }
339
340     public PyObject __rdivmod__(PyObject other) {
341         PyType self_type=getType();
342         PyObject impl=self_type.lookup("__rdivmod__");
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.__rdivmod__(other);
350     }
351
352     public PyObject __pow__(PyObject other) {
353         PyType self_type=getType();
354         PyObject impl=self_type.lookup("__pow__");
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.__pow__(other);
362     }
363
364     public PyObject __rpow__(PyObject other) {
365         PyType self_type=getType();
366         PyObject impl=self_type.lookup("__rpow__");
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.__rpow__(other);
374     }
375
376     public PyObject __lshift__(PyObject other) {
377         PyType self_type=getType();
378         PyObject impl=self_type.lookup("__lshift__");
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.__lshift__(other);
386     }
387
388     public PyObject __rlshift__(PyObject other) {
389         PyType self_type=getType();
390         PyObject impl=self_type.lookup("__rlshift__");
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.__rlshift__(other);
398     }
399
400     public PyObject __rshift__(PyObject other) {
401         PyType self_type=getType();
402         PyObject impl=self_type.lookup("__rshift__");
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.__rshift__(other);
410     }
411
412     public PyObject __rrshift__(PyObject other) {
413         PyType self_type=getType();
414         PyObject impl=self_type.lookup("__rrshift__");
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.__rrshift__(other);
422     }
423
424     public PyObject __and__(PyObject other) {
425         PyType self_type=getType();
426         PyObject impl=self_type.lookup("__and__");
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.__and__(other);
434     }
435
436     public PyObject __rand__(PyObject other) {
437         PyType self_type=getType();
438         PyObject impl=self_type.lookup("__rand__");
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.__rand__(other);
446     }
447
448     public PyObject __or__(PyObject other) {
449         PyType self_type=getType();
450         PyObject impl=self_type.lookup("__or__");
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.__or__(other);
458     }
459
460     public PyObject __ror__(PyObject other) {
461         PyType self_type=getType();
462         PyObject impl=self_type.lookup("__ror__");
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.__ror__(other);
470     }
471
472     public PyObject __xor__(PyObject other) {
473         PyType self_type=getType();
474         PyObject impl=self_type.lookup("__xor__");
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.__xor__(other);
482     }
483
484     public PyObject __rxor__(PyObject other) {
485         PyType self_type=getType();
486         PyObject impl=self_type.lookup("__rxor__");
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.__rxor__(other);
494     }
495
496     public PyObject __lt__(PyObject other) {
497         PyType self_type=getType();
498         PyObject impl=self_type.lookup("__lt__");
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.__lt__(other);
506     }
507
508     public PyObject __le__(PyObject other) {
509         PyType self_type=getType();
510         PyObject impl=self_type.lookup("__le__");
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.__le__(other);
518     }
519
520     public PyObject __gt__(PyObject other) {
521         PyType self_type=getType();
522         PyObject impl=self_type.lookup("__gt__");
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.__gt__(other);
530     }
531
532     public PyObject __ge__(PyObject other) {
533         PyType self_type=getType();
534         PyObject impl=self_type.lookup("__ge__");
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.__ge__(other);
542     }
543
544     public PyObject __eq__(PyObject other) {
545         PyType self_type=getType();
546         PyObject impl=self_type.lookup("__eq__");
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.__eq__(other);
554     }
555
556     public PyObject __ne__(PyObject other) {
557         PyType self_type=getType();
558         PyObject impl=self_type.lookup("__ne__");
559         if (impl!=null) {
560             PyObject res=impl.__get__(this,self_type).__call__(other);
561             if (res==Py.NotImplemented)
562                 return null;
563             return res;
564         }
565         return super.__ne__(other);
566     }
567
568     public PyObject __iadd__(PyObject other) {
569         PyType self_type=getType();
570         PyObject impl=self_type.lookup("__iadd__");
571         if (impl!=null)
572             return impl.__get__(this,self_type).__call__(other);
573         return super.__iadd__(other);
574     }
575
576     public PyObject __isub__(PyObject other) {
577         PyType self_type=getType();
578         PyObject impl=self_type.lookup("__isub__");
579         if (impl!=null)
580             return impl.__get__(this,self_type).__call__(other);
581         return super.__isub__(other);
582     }
583
584     public PyObject __imul__(PyObject other) {
585         PyType self_type=getType();
586         PyObject impl=self_type.lookup("__imul__");
587         if (impl!=null)
588             return impl.__get__(this,self_type).__call__(other);
589         return super.__imul__(other);
590     }
591
592     public PyObject __idiv__(PyObject other) {
593         PyType self_type=getType();
594         PyObject impl=self_type.lookup("__idiv__");
595         if (impl!=null)
596             return impl.__get__(this,self_type).__call__(other);
597         return super.__idiv__(other);
598     }
599
600     public PyObject __ifloordiv__(PyObject other) {
601         PyType self_type=getType();
602         PyObject impl=self_type.lookup("__ifloordiv__");
603         if (impl!=null)
604             return impl.__get__(this,self_type).__call__(other);
605         return super.__ifloordiv__(other);
606     }
607
608     public PyObject __itruediv__(PyObject other) {
609         PyType self_type=getType();
610         PyObject impl=self_type.lookup("__itruediv__");
611         if (impl!=null)
612             return impl.__get__(this,self_type).__call__(other);
613         return super.__itruediv__(other);
614     }
615
616     public PyObject __imod__(PyObject other) {
617         PyType self_type=getType();
618         PyObject impl=self_type.lookup("__imod__");
619         if (impl!=null)
620             return impl.__get__(this,self_type).__call__(other);
621         return super.__imod__(other);
622     }
623
624     public PyObject __ipow__(PyObject other) {
625         PyType self_type=getType();
626         PyObject impl=self_type.lookup("__ipow__");
627         if (impl!=null)
628             return impl.__get__(this,self_type).__call__(other);
629         return super.__ipow__(other);
630     }
631
632     public PyObject __ilshift__(PyObject other) {
633         PyType self_type=getType();
634         PyObject impl=self_type.lookup("__ilshift__");
635         if (impl!=null)
636             return impl.__get__(this,self_type).__call__(other);
637         return super.__ilshift__(other);
638     }
639
640     public PyObject __irshift__(PyObject other) {
641         PyType self_type=getType();
642         PyObject impl=self_type.lookup("__irshift__");
643         if (impl!=null)
644             return impl.__get__(this,self_type).__call__(other);
645         return super.__irshift__(other);
646     }
647
648     public PyObject __iand__(PyObject other) {
649         PyType self_type=getType();
650         PyObject impl=self_type.lookup("__iand__");
651         if (impl!=null)
652             return impl.__get__(this,self_type).__call__(other);
653         return super.__iand__(other);
654     }
655
656     public PyObject __ior__(PyObject other) {
657         PyType self_type=getType();
658         PyObject impl=self_type.lookup("__ior__");
659         if (impl!=null)
660             return impl.__get__(this,self_type).__call__(other);
661         return super.__ior__(other);
662     }
663
664     public PyObject __ixor__(PyObject other) {
665         PyType self_type=getType();
666         PyObject impl=self_type.lookup("__ixor__");
667         if (impl!=null)
668             return impl.__get__(this,self_type).__call__(other);
669         return super.__ixor__(other);
670     }
671
672     /*
673     public String toString() {
674         PyType self_type=getType();
675         PyObject impl=self_type.lookup("__repr__");
676         if (impl!=null) {
677             PyObject res=impl.__get__(this,self_type).__call__();
678             if (!(res instanceof PyString))
679                 throw Py.TypeError("__repr__ should return a string");
680             return((PyString)res).toString();
681         }
682         return super.toString();
683     }
684     */

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