001: package org.python.core;
002:
003: public class PyModuleDerived extends PyModule implements Slotted {
004:
005: public PyObject getSlot(int index) {
006: return slots[index];
007: }
008:
009: public void setSlot(int index, PyObject value) {
010: slots[index] = value;
011: }
012:
013: private PyObject[] slots;
014:
015: public PyModuleDerived(PyType subtype) {
016: super (subtype);
017: slots = new PyObject[subtype.getNumSlots()];
018: }
019:
020: public PyString __str__() {
021: PyType self_type = getType();
022: PyObject impl = self_type.lookup("__str__");
023: if (impl != null) {
024: PyObject res = impl.__get__(this , self_type).__call__();
025: if (res instanceof PyString)
026: return (PyString) res;
027: throw Py.TypeError("__str__" + " should return a "
028: + "string");
029: }
030: return super .__str__();
031: }
032:
033: public PyString __repr__() {
034: PyType self_type = getType();
035: PyObject impl = self_type.lookup("__repr__");
036: if (impl != null) {
037: PyObject res = impl.__get__(this , self_type).__call__();
038: if (res instanceof PyString)
039: return (PyString) res;
040: throw Py.TypeError("__repr__" + " should return a "
041: + "string");
042: }
043: return super .__repr__();
044: }
045:
046: public PyString __hex__() {
047: PyType self_type = getType();
048: PyObject impl = self_type.lookup("__hex__");
049: if (impl != null) {
050: PyObject res = impl.__get__(this , self_type).__call__();
051: if (res instanceof PyString)
052: return (PyString) res;
053: throw Py.TypeError("__hex__" + " should return a "
054: + "string");
055: }
056: return super .__hex__();
057: }
058:
059: public PyString __oct__() {
060: PyType self_type = getType();
061: PyObject impl = self_type.lookup("__oct__");
062: if (impl != null) {
063: PyObject res = impl.__get__(this , self_type).__call__();
064: if (res instanceof PyString)
065: return (PyString) res;
066: throw Py.TypeError("__oct__" + " should return a "
067: + "string");
068: }
069: return super .__oct__();
070: }
071:
072: public PyFloat __float__() {
073: PyType self_type = getType();
074: PyObject impl = self_type.lookup("__float__");
075: if (impl != null) {
076: PyObject res = impl.__get__(this , self_type).__call__();
077: if (res instanceof PyFloat)
078: return (PyFloat) res;
079: throw Py.TypeError("__float__" + " should return a "
080: + "float");
081: }
082: return super .__float__();
083: }
084:
085: public PyLong __long__() {
086: PyType self_type = getType();
087: PyObject impl = self_type.lookup("__long__");
088: if (impl != null) {
089: PyObject res = impl.__get__(this , self_type).__call__();
090: if (res instanceof PyLong)
091: return (PyLong) res;
092: throw Py.TypeError("__long__" + " should return a "
093: + "long");
094: }
095: return super .__long__();
096: }
097:
098: public PyComplex __complex__() {
099: PyType self_type = getType();
100: PyObject impl = self_type.lookup("__complex__");
101: if (impl != null) {
102: PyObject res = impl.__get__(this , self_type).__call__();
103: if (res instanceof PyComplex)
104: return (PyComplex) res;
105: throw Py.TypeError("__complex__" + " should return a "
106: + "complex");
107: }
108: return super .__complex__();
109: }
110:
111: public PyObject __pos__() {
112: PyType self_type = getType();
113: PyObject impl = self_type.lookup("__pos__");
114: if (impl != null)
115: return impl.__get__(this , self_type).__call__();
116: return super .__pos__();
117: }
118:
119: public PyObject __neg__() {
120: PyType self_type = getType();
121: PyObject impl = self_type.lookup("__neg__");
122: if (impl != null)
123: return impl.__get__(this , self_type).__call__();
124: return super .__neg__();
125: }
126:
127: public PyObject __abs__() {
128: PyType self_type = getType();
129: PyObject impl = self_type.lookup("__abs__");
130: if (impl != null)
131: return impl.__get__(this , self_type).__call__();
132: return super .__abs__();
133: }
134:
135: public PyObject __invert__() {
136: PyType self_type = getType();
137: PyObject impl = self_type.lookup("__invert__");
138: if (impl != null)
139: return impl.__get__(this , self_type).__call__();
140: return super .__invert__();
141: }
142:
143: public PyObject __reduce__() {
144: PyType self_type = getType();
145: PyObject impl = self_type.lookup("__reduce__");
146: if (impl != null)
147: return impl.__get__(this , self_type).__call__();
148: return super .__reduce__();
149: }
150:
151: public PyObject __add__(PyObject other) {
152: PyType self_type = getType();
153: PyObject impl = self_type.lookup("__add__");
154: if (impl != null) {
155: PyObject res = impl.__get__(this , self_type)
156: .__call__(other);
157: if (res == Py.NotImplemented)
158: return null;
159: return res;
160: }
161: return super .__add__(other);
162: }
163:
164: public PyObject __radd__(PyObject other) {
165: PyType self_type = getType();
166: PyObject impl = self_type.lookup("__radd__");
167: if (impl != null) {
168: PyObject res = impl.__get__(this , self_type)
169: .__call__(other);
170: if (res == Py.NotImplemented)
171: return null;
172: return res;
173: }
174: return super .__radd__(other);
175: }
176:
177: public PyObject __sub__(PyObject other) {
178: PyType self_type = getType();
179: PyObject impl = self_type.lookup("__sub__");
180: if (impl != null) {
181: PyObject res = impl.__get__(this , self_type)
182: .__call__(other);
183: if (res == Py.NotImplemented)
184: return null;
185: return res;
186: }
187: return super .__sub__(other);
188: }
189:
190: public PyObject __rsub__(PyObject other) {
191: PyType self_type = getType();
192: PyObject impl = self_type.lookup("__rsub__");
193: if (impl != null) {
194: PyObject res = impl.__get__(this , self_type)
195: .__call__(other);
196: if (res == Py.NotImplemented)
197: return null;
198: return res;
199: }
200: return super .__rsub__(other);
201: }
202:
203: public PyObject __mul__(PyObject other) {
204: PyType self_type = getType();
205: PyObject impl = self_type.lookup("__mul__");
206: if (impl != null) {
207: PyObject res = impl.__get__(this , self_type)
208: .__call__(other);
209: if (res == Py.NotImplemented)
210: return null;
211: return res;
212: }
213: return super .__mul__(other);
214: }
215:
216: public PyObject __rmul__(PyObject other) {
217: PyType self_type = getType();
218: PyObject impl = self_type.lookup("__rmul__");
219: if (impl != null) {
220: PyObject res = impl.__get__(this , self_type)
221: .__call__(other);
222: if (res == Py.NotImplemented)
223: return null;
224: return res;
225: }
226: return super .__rmul__(other);
227: }
228:
229: public PyObject __div__(PyObject other) {
230: PyType self_type = getType();
231: PyObject impl = self_type.lookup("__div__");
232: if (impl != null) {
233: PyObject res = impl.__get__(this , self_type)
234: .__call__(other);
235: if (res == Py.NotImplemented)
236: return null;
237: return res;
238: }
239: return super .__div__(other);
240: }
241:
242: public PyObject __rdiv__(PyObject other) {
243: PyType self_type = getType();
244: PyObject impl = self_type.lookup("__rdiv__");
245: if (impl != null) {
246: PyObject res = impl.__get__(this , self_type)
247: .__call__(other);
248: if (res == Py.NotImplemented)
249: return null;
250: return res;
251: }
252: return super .__rdiv__(other);
253: }
254:
255: public PyObject __floordiv__(PyObject other) {
256: PyType self_type = getType();
257: PyObject impl = self_type.lookup("__floordiv__");
258: if (impl != null) {
259: PyObject res = impl.__get__(this , self_type)
260: .__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)
273: .__call__(other);
274: if (res == Py.NotImplemented)
275: return null;
276: return res;
277: }
278: return super .__rfloordiv__(other);
279: }
280:
281: public PyObject __truediv__(PyObject other) {
282: PyType self_type = getType();
283: PyObject impl = self_type.lookup("__truediv__");
284: if (impl != null) {
285: PyObject res = impl.__get__(this , self_type)
286: .__call__(other);
287: if (res == Py.NotImplemented)
288: return null;
289: return res;
290: }
291: return super .__truediv__(other);
292: }
293:
294: public PyObject __rtruediv__(PyObject other) {
295: PyType self_type = getType();
296: PyObject impl = self_type.lookup("__rtruediv__");
297: if (impl != null) {
298: PyObject res = impl.__get__(this , self_type)
299: .__call__(other);
300: if (res == Py.NotImplemented)
301: return null;
302: return res;
303: }
304: return super .__rtruediv__(other);
305: }
306:
307: public PyObject __mod__(PyObject other) {
308: PyType self_type = getType();
309: PyObject impl = self_type.lookup("__mod__");
310: if (impl != null) {
311: PyObject res = impl.__get__(this , self_type)
312: .__call__(other);
313: if (res == Py.NotImplemented)
314: return null;
315: return res;
316: }
317: return super .__mod__(other);
318: }
319:
320: public PyObject __rmod__(PyObject other) {
321: PyType self_type = getType();
322: PyObject impl = self_type.lookup("__rmod__");
323: if (impl != null) {
324: PyObject res = impl.__get__(this , self_type)
325: .__call__(other);
326: if (res == Py.NotImplemented)
327: return null;
328: return res;
329: }
330: return super .__rmod__(other);
331: }
332:
333: public PyObject __divmod__(PyObject other) {
334: PyType self_type = getType();
335: PyObject impl = self_type.lookup("__divmod__");
336: if (impl != null) {
337: PyObject res = impl.__get__(this , self_type)
338: .__call__(other);
339: if (res == Py.NotImplemented)
340: return null;
341: return res;
342: }
343: return super .__divmod__(other);
344: }
345:
346: public PyObject __rdivmod__(PyObject other) {
347: PyType self_type = getType();
348: PyObject impl = self_type.lookup("__rdivmod__");
349: if (impl != null) {
350: PyObject res = impl.__get__(this , self_type)
351: .__call__(other);
352: if (res == Py.NotImplemented)
353: return null;
354: return res;
355: }
356: return super .__rdivmod__(other);
357: }
358:
359: public PyObject __pow__(PyObject other) {
360: PyType self_type = getType();
361: PyObject impl = self_type.lookup("__pow__");
362: if (impl != null) {
363: PyObject res = impl.__get__(this , self_type)
364: .__call__(other);
365: if (res == Py.NotImplemented)
366: return null;
367: return res;
368: }
369: return super .__pow__(other);
370: }
371:
372: public PyObject __rpow__(PyObject other) {
373: PyType self_type = getType();
374: PyObject impl = self_type.lookup("__rpow__");
375: if (impl != null) {
376: PyObject res = impl.__get__(this , self_type)
377: .__call__(other);
378: if (res == Py.NotImplemented)
379: return null;
380: return res;
381: }
382: return super .__rpow__(other);
383: }
384:
385: public PyObject __lshift__(PyObject other) {
386: PyType self_type = getType();
387: PyObject impl = self_type.lookup("__lshift__");
388: if (impl != null) {
389: PyObject res = impl.__get__(this , self_type)
390: .__call__(other);
391: if (res == Py.NotImplemented)
392: return null;
393: return res;
394: }
395: return super .__lshift__(other);
396: }
397:
398: public PyObject __rlshift__(PyObject other) {
399: PyType self_type = getType();
400: PyObject impl = self_type.lookup("__rlshift__");
401: if (impl != null) {
402: PyObject res = impl.__get__(this , self_type)
403: .__call__(other);
404: if (res == Py.NotImplemented)
405: return null;
406: return res;
407: }
408: return super .__rlshift__(other);
409: }
410:
411: public PyObject __rshift__(PyObject other) {
412: PyType self_type = getType();
413: PyObject impl = self_type.lookup("__rshift__");
414: if (impl != null) {
415: PyObject res = impl.__get__(this , self_type)
416: .__call__(other);
417: if (res == Py.NotImplemented)
418: return null;
419: return res;
420: }
421: return super .__rshift__(other);
422: }
423:
424: public PyObject __rrshift__(PyObject other) {
425: PyType self_type = getType();
426: PyObject impl = self_type.lookup("__rrshift__");
427: if (impl != null) {
428: PyObject res = impl.__get__(this , self_type)
429: .__call__(other);
430: if (res == Py.NotImplemented)
431: return null;
432: return res;
433: }
434: return super .__rrshift__(other);
435: }
436:
437: public PyObject __and__(PyObject other) {
438: PyType self_type = getType();
439: PyObject impl = self_type.lookup("__and__");
440: if (impl != null) {
441: PyObject res = impl.__get__(this , self_type)
442: .__call__(other);
443: if (res == Py.NotImplemented)
444: return null;
445: return res;
446: }
447: return super .__and__(other);
448: }
449:
450: public PyObject __rand__(PyObject other) {
451: PyType self_type = getType();
452: PyObject impl = self_type.lookup("__rand__");
453: if (impl != null) {
454: PyObject res = impl.__get__(this , self_type)
455: .__call__(other);
456: if (res == Py.NotImplemented)
457: return null;
458: return res;
459: }
460: return super .__rand__(other);
461: }
462:
463: public PyObject __or__(PyObject other) {
464: PyType self_type = getType();
465: PyObject impl = self_type.lookup("__or__");
466: if (impl != null) {
467: PyObject res = impl.__get__(this , self_type)
468: .__call__(other);
469: if (res == Py.NotImplemented)
470: return null;
471: return res;
472: }
473: return super .__or__(other);
474: }
475:
476: public PyObject __ror__(PyObject other) {
477: PyType self_type = getType();
478: PyObject impl = self_type.lookup("__ror__");
479: if (impl != null) {
480: PyObject res = impl.__get__(this , self_type)
481: .__call__(other);
482: if (res == Py.NotImplemented)
483: return null;
484: return res;
485: }
486: return super .__ror__(other);
487: }
488:
489: public PyObject __xor__(PyObject other) {
490: PyType self_type = getType();
491: PyObject impl = self_type.lookup("__xor__");
492: if (impl != null) {
493: PyObject res = impl.__get__(this , self_type)
494: .__call__(other);
495: if (res == Py.NotImplemented)
496: return null;
497: return res;
498: }
499: return super .__xor__(other);
500: }
501:
502: public PyObject __rxor__(PyObject other) {
503: PyType self_type = getType();
504: PyObject impl = self_type.lookup("__rxor__");
505: if (impl != null) {
506: PyObject res = impl.__get__(this , self_type)
507: .__call__(other);
508: if (res == Py.NotImplemented)
509: return null;
510: return res;
511: }
512: return super .__rxor__(other);
513: }
514:
515: public PyObject __lt__(PyObject other) {
516: PyType self_type = getType();
517: PyObject impl = self_type.lookup("__lt__");
518: if (impl != null) {
519: PyObject res = impl.__get__(this , self_type)
520: .__call__(other);
521: if (res == Py.NotImplemented)
522: return null;
523: return res;
524: }
525: return super .__lt__(other);
526: }
527:
528: public PyObject __le__(PyObject other) {
529: PyType self_type = getType();
530: PyObject impl = self_type.lookup("__le__");
531: if (impl != null) {
532: PyObject res = impl.__get__(this , self_type)
533: .__call__(other);
534: if (res == Py.NotImplemented)
535: return null;
536: return res;
537: }
538: return super .__le__(other);
539: }
540:
541: public PyObject __gt__(PyObject other) {
542: PyType self_type = getType();
543: PyObject impl = self_type.lookup("__gt__");
544: if (impl != null) {
545: PyObject res = impl.__get__(this , self_type)
546: .__call__(other);
547: if (res == Py.NotImplemented)
548: return null;
549: return res;
550: }
551: return super .__gt__(other);
552: }
553:
554: public PyObject __ge__(PyObject other) {
555: PyType self_type = getType();
556: PyObject impl = self_type.lookup("__ge__");
557: if (impl != null) {
558: PyObject res = impl.__get__(this , self_type)
559: .__call__(other);
560: if (res == Py.NotImplemented)
561: return null;
562: return res;
563: }
564: return super .__ge__(other);
565: }
566:
567: public PyObject __eq__(PyObject other) {
568: PyType self_type = getType();
569: PyObject impl = self_type.lookup("__eq__");
570: if (impl != null) {
571: PyObject res = impl.__get__(this , self_type)
572: .__call__(other);
573: if (res == Py.NotImplemented)
574: return null;
575: return res;
576: }
577: return super .__eq__(other);
578: }
579:
580: public PyObject __ne__(PyObject other) {
581: PyType self_type = getType();
582: PyObject impl = self_type.lookup("__ne__");
583: if (impl != null) {
584: PyObject res = impl.__get__(this , self_type)
585: .__call__(other);
586: if (res == Py.NotImplemented)
587: return null;
588: return res;
589: }
590: return super .__ne__(other);
591: }
592:
593: public PyObject __iadd__(PyObject other) {
594: PyType self_type = getType();
595: PyObject impl = self_type.lookup("__iadd__");
596: if (impl != null)
597: return impl.__get__(this , self_type).__call__(other);
598: return super .__iadd__(other);
599: }
600:
601: public PyObject __isub__(PyObject other) {
602: PyType self_type = getType();
603: PyObject impl = self_type.lookup("__isub__");
604: if (impl != null)
605: return impl.__get__(this , self_type).__call__(other);
606: return super .__isub__(other);
607: }
608:
609: public PyObject __imul__(PyObject other) {
610: PyType self_type = getType();
611: PyObject impl = self_type.lookup("__imul__");
612: if (impl != null)
613: return impl.__get__(this , self_type).__call__(other);
614: return super .__imul__(other);
615: }
616:
617: public PyObject __idiv__(PyObject other) {
618: PyType self_type = getType();
619: PyObject impl = self_type.lookup("__idiv__");
620: if (impl != null)
621: return impl.__get__(this , self_type).__call__(other);
622: return super .__idiv__(other);
623: }
624:
625: public PyObject __ifloordiv__(PyObject other) {
626: PyType self_type = getType();
627: PyObject impl = self_type.lookup("__ifloordiv__");
628: if (impl != null)
629: return impl.__get__(this , self_type).__call__(other);
630: return super .__ifloordiv__(other);
631: }
632:
633: public PyObject __itruediv__(PyObject other) {
634: PyType self_type = getType();
635: PyObject impl = self_type.lookup("__itruediv__");
636: if (impl != null)
637: return impl.__get__(this , self_type).__call__(other);
638: return super .__itruediv__(other);
639: }
640:
641: public PyObject __imod__(PyObject other) {
642: PyType self_type = getType();
643: PyObject impl = self_type.lookup("__imod__");
644: if (impl != null)
645: return impl.__get__(this , self_type).__call__(other);
646: return super .__imod__(other);
647: }
648:
649: public PyObject __ipow__(PyObject other) {
650: PyType self_type = getType();
651: PyObject impl = self_type.lookup("__ipow__");
652: if (impl != null)
653: return impl.__get__(this , self_type).__call__(other);
654: return super .__ipow__(other);
655: }
656:
657: public PyObject __ilshift__(PyObject other) {
658: PyType self_type = getType();
659: PyObject impl = self_type.lookup("__ilshift__");
660: if (impl != null)
661: return impl.__get__(this , self_type).__call__(other);
662: return super .__ilshift__(other);
663: }
664:
665: public PyObject __irshift__(PyObject other) {
666: PyType self_type = getType();
667: PyObject impl = self_type.lookup("__irshift__");
668: if (impl != null)
669: return impl.__get__(this , self_type).__call__(other);
670: return super .__irshift__(other);
671: }
672:
673: public PyObject __iand__(PyObject other) {
674: PyType self_type = getType();
675: PyObject impl = self_type.lookup("__iand__");
676: if (impl != null)
677: return impl.__get__(this , self_type).__call__(other);
678: return super .__iand__(other);
679: }
680:
681: public PyObject __ior__(PyObject other) {
682: PyType self_type = getType();
683: PyObject impl = self_type.lookup("__ior__");
684: if (impl != null)
685: return impl.__get__(this , self_type).__call__(other);
686: return super .__ior__(other);
687: }
688:
689: public PyObject __ixor__(PyObject other) {
690: PyType self_type = getType();
691: PyObject impl = self_type.lookup("__ixor__");
692: if (impl != null)
693: return impl.__get__(this , self_type).__call__(other);
694: return super .__ixor__(other);
695: }
696:
697: public PyObject __int__() {
698: PyType self_type = getType();
699: PyObject impl = self_type.lookup("__int__");
700: if (impl != null) {
701: PyObject res = impl.__get__(this , self_type).__call__();
702: if (res instanceof PyInteger || res instanceof PyLong)
703: return (PyObject) res;
704: throw Py.TypeError("__int__" + " should return an integer");
705: }
706: return super .__int__();
707: }
708:
709: public String toString() {
710: PyType self_type = getType();
711: PyObject impl = self_type.lookup("__repr__");
712: if (impl != null) {
713: PyObject res = impl.__get__(this , self_type).__call__();
714: if (!(res instanceof PyString))
715: throw Py.TypeError("__repr__ should return a string");
716: return ((PyString) res).toString();
717: }
718: return super .toString();
719: }
720:
721: public int hashCode() {
722: PyType self_type = getType();
723: PyObject impl = self_type.lookup("__hash__");
724: if (impl != null) {
725: PyObject res = impl.__get__(this , self_type).__call__();
726: if (res instanceof PyInteger)
727: return ((PyInteger) res).getValue();
728: throw Py.TypeError("__hash__ should return a int");
729: }
730: if (self_type.lookup("__eq__") != null
731: || self_type.lookup("__cmp__") != null)
732: throw Py.TypeError("unhashable type");
733: return super .hashCode();
734: }
735:
736: public PyUnicode __unicode__() {
737: PyType self_type = getType();
738: PyObject impl = self_type.lookup("__unicode__");
739: if (impl != null) {
740: PyObject res = impl.__get__(this , self_type).__call__();
741: if (res instanceof PyUnicode)
742: return (PyUnicode) res;
743: if (res instanceof PyString)
744: return new PyUnicode((PyString) res);
745: throw Py.TypeError("__unicode__" + " should return a "
746: + "unicode");
747: }
748: return super .__unicode__();
749: }
750:
751: public int __cmp__(PyObject other) {
752: PyType self_type = getType();
753: PyObject impl = self_type.lookup("__cmp__");
754: if (impl != null) {
755: PyObject res = impl.__get__(this , self_type)
756: .__call__(other);
757: if (res instanceof PyInteger) {
758: int v = ((PyInteger) res).getValue();
759: return v < 0 ? -1 : v > 0 ? 1 : 0;
760: }
761: throw Py.TypeError("__cmp__ should return a int");
762: }
763: return super .__cmp__(other);
764: }
765:
766: public boolean __nonzero__() {
767: PyType self_type = getType();
768: PyObject impl = self_type.lookup("__nonzero__");
769: if (impl == null) {
770: impl = self_type.lookup("__len__");
771: if (impl == null)
772: return super .__nonzero__();
773: }
774: return impl.__get__(this , self_type).__call__().__nonzero__();
775: }
776:
777: public boolean __contains__(PyObject o) {
778: PyType self_type = getType();
779: PyObject impl = self_type.lookup("__contains__");
780: if (impl == null)
781: return super .__contains__(o);
782: return impl.__get__(this , self_type).__call__(o).__nonzero__();
783: }
784:
785: public int __len__() {
786: PyType self_type = getType();
787: PyObject impl = self_type.lookup("__len__");
788: if (impl != null) {
789: PyObject res = impl.__get__(this , self_type).__call__();
790: if (res instanceof PyInteger)
791: return ((PyInteger) res).getValue();
792: throw Py.TypeError("__len__ should return a int");
793: }
794: return super .__len__();
795: }
796:
797: public PyObject __iter__() {
798: PyType self_type = getType();
799: PyObject impl = self_type.lookup("__iter__");
800: if (impl != null)
801: return impl.__get__(this , self_type).__call__();
802: impl = self_type.lookup("__getitem__");
803: if (impl == null)
804: return super .__iter__();
805: return new PySequenceIter(this );
806: }
807:
808: public PyObject __iternext__() {
809: PyType self_type = getType();
810: PyObject impl = self_type.lookup("next");
811: if (impl != null) {
812: try {
813: return impl.__get__(this , self_type).__call__();
814: } catch (PyException exc) {
815: if (Py.matchException(exc, Py.StopIteration))
816: return null;
817: throw exc;
818: }
819: }
820: return super .__iternext__(); // ???
821: }
822:
823: public PyObject __finditem__(PyObject key) { // ???
824: PyType self_type = getType();
825: PyObject impl = self_type.lookup("__getitem__");
826: if (impl != null)
827: try {
828: return impl.__get__(this , self_type).__call__(key);
829: } catch (PyException exc) {
830: if (Py.matchException(exc, Py.LookupError))
831: return null;
832: throw exc;
833: }
834: return super .__finditem__(key);
835: }
836:
837: public void __setitem__(PyObject key, PyObject value) { // ???
838: PyType self_type = getType();
839: PyObject impl = self_type.lookup("__setitem__");
840: if (impl != null) {
841: impl.__get__(this , self_type).__call__(key, value);
842: return;
843: }
844: super .__setitem__(key, value);
845: }
846:
847: public PyObject __getslice__(PyObject start, PyObject stop,
848: PyObject step) { // ???
849: PyType self_type = getType();
850: PyObject impl = self_type.lookup("__getslice__");
851: if (impl != null)
852: try {
853: return impl.__get__(this , self_type).__call__(start,
854: stop);
855: } catch (PyException exc) {
856: if (Py.matchException(exc, Py.LookupError))
857: return null;
858: throw exc;
859: }
860: return super .__getslice__(start, stop, step);
861: }
862:
863: public void __delitem__(PyObject key) { // ???
864: PyType self_type = getType();
865: PyObject impl = self_type.lookup("__delitem__");
866: if (impl != null) {
867: impl.__get__(this , self_type).__call__(key);
868: return;
869: }
870: super .__delitem__(key);
871: }
872:
873: public PyObject __call__(PyObject args[], String keywords[]) {
874: ThreadState ts = Py.getThreadState();
875: if (ts.recursion_depth++ > ts.systemState.getrecursionlimit())
876: throw Py
877: .RuntimeError("maximum __call__ recursion depth exceeded");
878: try {
879: PyType self_type = getType();
880: PyObject impl = self_type.lookup("__call__");
881: if (impl != null)
882: return impl.__get__(this , self_type).__call__(args,
883: keywords);
884: return super .__call__(args, keywords);
885: } finally {
886: --ts.recursion_depth;
887: }
888: }
889:
890: public PyObject __findattr__(String name) {
891: PyType self_type = getType();
892: PyObject getattribute = self_type.lookup("__getattribute__");
893: PyString py_name = null;
894: try {
895: if (getattribute != null) {
896: return getattribute.__get__(this , self_type).__call__(
897: py_name = new PyString(name));
898: } else {
899: return super .__findattr__(name);
900: }
901: } catch (PyException e) {
902: if (Py.matchException(e, Py.AttributeError)) {
903: PyObject getattr = self_type.lookup("__getattr__");
904: if (getattr != null)
905: try {
906: return getattr.__get__(this , self_type)
907: .__call__(
908: py_name != null ? py_name
909: : new PyString(name));
910: } catch (PyException e1) {
911: if (!Py.matchException(e1, Py.AttributeError))
912: throw e1;
913: }
914: return null;
915: }
916: throw e;
917: }
918: }
919:
920: public void __setattr__(String name, PyObject value) {
921: PyType self_type = getType();
922: PyObject impl = self_type.lookup("__setattr__");
923: if (impl != null) {
924: impl.__get__(this , self_type).__call__(new PyString(name),
925: value);
926: return;
927: }
928: super .__setattr__(name, value);
929: }
930:
931: public void __delattr__(String name) {
932: PyType self_type = getType();
933: PyObject impl = self_type.lookup("__delattr__");
934: if (impl != null) {
935: impl.__get__(this , self_type).__call__(new PyString(name));
936: return;
937: }
938: super .__delattr__(name);
939: }
940:
941: public PyObject __get__(PyObject obj, PyObject type) {
942: PyType self_type = getType();
943: PyObject impl = self_type.lookup("__get__");
944: if (impl != null) {
945: if (obj == null)
946: obj = Py.None;
947: if (type == null)
948: type = Py.None;
949: return impl.__get__(this , self_type).__call__(obj, type);
950: }
951: return super .__get__(obj, type);
952: }
953:
954: public void __set__(PyObject obj, PyObject value) {
955: PyType self_type = getType();
956: PyObject impl = self_type.lookup("__set__");
957: if (impl != null) {
958: impl.__get__(this , self_type).__call__(obj, value);
959: return;
960: }
961: super .__set__(obj, value);
962: }
963:
964: public void __delete__(PyObject obj) {
965: PyType self_type = getType();
966: PyObject impl = self_type.lookup("__delete__");
967: if (impl != null) {
968: impl.__get__(this , self_type).__call__(obj);
969: return;
970: }
971: super .__delete__(obj);
972: }
973:
974: public void dispatch__init__(PyType type, PyObject[] args,
975: String[] keywords) {
976: PyType self_type = getType();
977: if (self_type.isSubType(type)) {
978: PyObject impl = self_type.lookup("__init__");
979: if (impl != null)
980: impl.__get__(this, self_type).__call__(args, keywords);
981: }
982: }
983:
984: }
|