1 package org.python.core; 3 4 import java.io.Serializable ; 5 6 9 public class PyInteger extends PyObject { 10 11 12 public static final String exposed_name = "int"; 13 14 public static void typeSetup(PyObject dict, PyType.Newstyle marker) { 15 class exposed___abs__ extends PyBuiltinFunctionNarrow { 16 17 private PyInteger self; 18 19 public PyObject getSelf() { 20 return self; 21 } 22 23 exposed___abs__(PyInteger self, PyBuiltinFunction.Info info) { 24 super(info); 25 this.self = self; 26 } 27 28 public PyBuiltinFunction makeBound(PyObject self) { 29 return new exposed___abs__((PyInteger) self, info); 30 } 31 32 public PyObject __call__() { 33 return self.int___abs__(); 34 } 35 36 public PyObject inst_call(PyObject gself) { 37 PyInteger self = (PyInteger) gself; 38 return self.int___abs__(); 39 } 40 41 } 42 dict.__setitem__("__abs__", new PyMethodDescr("__abs__", 43 PyInteger.class, 0, 0, new exposed___abs__(null, null))); 44 class exposed___float__ extends PyBuiltinFunctionNarrow { 45 46 private PyInteger self; 47 48 public PyObject getSelf() { 49 return self; 50 } 51 52 exposed___float__(PyInteger self, PyBuiltinFunction.Info info) { 53 super(info); 54 this.self = self; 55 } 56 57 public PyBuiltinFunction makeBound(PyObject self) { 58 return new exposed___float__((PyInteger) self, info); 59 } 60 61 public PyObject __call__() { 62 return self.int___float__(); 63 } 64 65 public PyObject inst_call(PyObject gself) { 66 PyInteger self = (PyInteger) gself; 67 return self.int___float__(); 68 } 69 70 } 71 dict.__setitem__("__float__", new PyMethodDescr("__float__", 72 PyInteger.class, 0, 0, new exposed___float__(null, null))); 73 class exposed___hex__ extends PyBuiltinFunctionNarrow { 74 75 private PyInteger self; 76 77 public PyObject getSelf() { 78 return self; 79 } 80 81 exposed___hex__(PyInteger self, PyBuiltinFunction.Info info) { 82 super(info); 83 this.self = self; 84 } 85 86 public PyBuiltinFunction makeBound(PyObject self) { 87 return new exposed___hex__((PyInteger) self, info); 88 } 89 90 public PyObject __call__() { 91 return self.int___hex__(); 92 } 93 94 public PyObject inst_call(PyObject gself) { 95 PyInteger self = (PyInteger) gself; 96 return self.int___hex__(); 97 } 98 99 } 100 dict.__setitem__("__hex__", new PyMethodDescr("__hex__", 101 PyInteger.class, 0, 0, new exposed___hex__(null, null))); 102 class exposed___int__ extends PyBuiltinFunctionNarrow { 103 104 private PyInteger self; 105 106 public PyObject getSelf() { 107 return self; 108 } 109 110 exposed___int__(PyInteger self, PyBuiltinFunction.Info info) { 111 super(info); 112 this.self = self; 113 } 114 115 public PyBuiltinFunction makeBound(PyObject self) { 116 return new exposed___int__((PyInteger) self, info); 117 } 118 119 public PyObject __call__() { 120 return self.int___int__(); 121 } 122 123 public PyObject inst_call(PyObject gself) { 124 PyInteger self = (PyInteger) gself; 125 return self.int___int__(); 126 } 127 128 } 129 dict.__setitem__("__int__", new PyMethodDescr("__int__", 130 PyInteger.class, 0, 0, new exposed___int__(null, null))); 131 class exposed___invert__ extends PyBuiltinFunctionNarrow { 132 133 private PyInteger self; 134 135 public PyObject getSelf() { 136 return self; 137 } 138 139 exposed___invert__(PyInteger self, PyBuiltinFunction.Info info) { 140 super(info); 141 this.self = self; 142 } 143 144 public PyBuiltinFunction makeBound(PyObject self) { 145 return new exposed___invert__((PyInteger) self, info); 146 } 147 148 public PyObject __call__() { 149 return self.int___invert__(); 150 } 151 152 public PyObject inst_call(PyObject gself) { 153 PyInteger self = (PyInteger) gself; 154 return self.int___invert__(); 155 } 156 157 } 158 dict.__setitem__("__invert__", new PyMethodDescr("__invert__", 159 PyInteger.class, 0, 0, new exposed___invert__(null, null))); 160 class exposed___long__ extends PyBuiltinFunctionNarrow { 161 162 private PyInteger self; 163 164 public PyObject getSelf() { 165 return self; 166 } 167 168 exposed___long__(PyInteger self, PyBuiltinFunction.Info info) { 169 super(info); 170 this.self = self; 171 } 172 173 public PyBuiltinFunction makeBound(PyObject self) { 174 return new exposed___long__((PyInteger) self, info); 175 } 176 177 public PyObject __call__() { 178 return self.int___long__(); 179 } 180 181 public PyObject inst_call(PyObject gself) { 182 PyInteger self = (PyInteger) gself; 183 return self.int___long__(); 184 } 185 186 } 187 dict.__setitem__("__long__", new PyMethodDescr("__long__", 188 PyInteger.class, 0, 0, new exposed___long__(null, null))); 189 class exposed___neg__ extends PyBuiltinFunctionNarrow { 190 191 private PyInteger self; 192 193 public PyObject getSelf() { 194 return self; 195 } 196 197 exposed___neg__(PyInteger self, PyBuiltinFunction.Info info) { 198 super(info); 199 this.self = self; 200 } 201 202 public PyBuiltinFunction makeBound(PyObject self) { 203 return new exposed___neg__((PyInteger) self, info); 204 } 205 206 public PyObject __call__() { 207 return self.int___neg__(); 208 } 209 210 public PyObject inst_call(PyObject gself) { 211 PyInteger self = (PyInteger) gself; 212 return self.int___neg__(); 213 } 214 215 } 216 dict.__setitem__("__neg__", new PyMethodDescr("__neg__", 217 PyInteger.class, 0, 0, new exposed___neg__(null, null))); 218 class exposed___oct__ extends PyBuiltinFunctionNarrow { 219 220 private PyInteger self; 221 222 public PyObject getSelf() { 223 return self; 224 } 225 226 exposed___oct__(PyInteger self, PyBuiltinFunction.Info info) { 227 super(info); 228 this.self = self; 229 } 230 231 public PyBuiltinFunction makeBound(PyObject self) { 232 return new exposed___oct__((PyInteger) self, info); 233 } 234 235 public PyObject __call__() { 236 return self.int___oct__(); 237 } 238 239 public PyObject inst_call(PyObject gself) { 240 PyInteger self = (PyInteger) gself; 241 return self.int___oct__(); 242 } 243 244 } 245 dict.__setitem__("__oct__", new PyMethodDescr("__oct__", 246 PyInteger.class, 0, 0, new exposed___oct__(null, null))); 247 class exposed___pos__ extends PyBuiltinFunctionNarrow { 248 249 private PyInteger self; 250 251 public PyObject getSelf() { 252 return self; 253 } 254 255 exposed___pos__(PyInteger self, PyBuiltinFunction.Info info) { 256 super(info); 257 this.self = self; 258 } 259 260 public PyBuiltinFunction makeBound(PyObject self) { 261 return new exposed___pos__((PyInteger) self, info); 262 } 263 264 public PyObject __call__() { 265 return self.int___pos__(); 266 } 267 268 public PyObject inst_call(PyObject gself) { 269 PyInteger self = (PyInteger) gself; 270 return self.int___pos__(); 271 } 272 273 } 274 dict.__setitem__("__pos__", new PyMethodDescr("__pos__", 275 PyInteger.class, 0, 0, new exposed___pos__(null, null))); 276 class exposed___add__ extends PyBuiltinFunctionNarrow { 277 278 private PyInteger self; 279 280 public PyObject getSelf() { 281 return self; 282 } 283 284 exposed___add__(PyInteger self, PyBuiltinFunction.Info info) { 285 super(info); 286 this.self = self; 287 } 288 289 public PyBuiltinFunction makeBound(PyObject self) { 290 return new exposed___add__((PyInteger) self, info); 291 } 292 293 public PyObject __call__(PyObject arg0) { 294 PyObject ret = self.int___add__(arg0); 295 if (ret == null) 296 return Py.NotImplemented; 297 return ret; 298 } 299 300 public PyObject inst_call(PyObject gself, PyObject arg0) { 301 PyInteger self = (PyInteger) gself; 302 PyObject ret = self.int___add__(arg0); 303 if (ret == null) 304 return Py.NotImplemented; 305 return ret; 306 } 307 308 } 309 dict.__setitem__("__add__", new PyMethodDescr("__add__", 310 PyInteger.class, 1, 1, new exposed___add__(null, null))); 311 class exposed___and__ extends PyBuiltinFunctionNarrow { 312 313 private PyInteger self; 314 315 public PyObject getSelf() { 316 return self; 317 } 318 319 exposed___and__(PyInteger self, PyBuiltinFunction.Info info) { 320 super(info); 321 this.self = self; 322 } 323 324 public PyBuiltinFunction makeBound(PyObject self) { 325 return new exposed___and__((PyInteger) self, info); 326 } 327 328 public PyObject __call__(PyObject arg0) { 329 PyObject ret = self.int___and__(arg0); 330 if (ret == null) 331 return Py.NotImplemented; 332 return ret; 333 } 334 335 public PyObject inst_call(PyObject gself, PyObject arg0) { 336 PyInteger self = (PyInteger) gself; 337 PyObject ret = self.int___and__(arg0); 338 if (ret == null) 339 return Py.NotImplemented; 340 return ret; 341 } 342 343 } 344 dict.__setitem__("__and__", new PyMethodDescr("__and__", 345 PyInteger.class, 1, 1, new exposed___and__(null, null))); 346 class exposed___div__ extends PyBuiltinFunctionNarrow { 347 348 private PyInteger self; 349 350 public PyObject getSelf() { 351 return self; 352 } 353 354 exposed___div__(PyInteger self, PyBuiltinFunction.Info info) { 355 super(info); 356 this.self = self; 357 } 358 359 public PyBuiltinFunction makeBound(PyObject self) { 360 return new exposed___div__((PyInteger) self, info); 361 } 362 363 public PyObject __call__(PyObject arg0) { 364 PyObject ret = self.int___div__(arg0); 365 if (ret == null) 366 return Py.NotImplemented; 367 return ret; 368 } 369 370 public PyObject inst_call(PyObject gself, PyObject arg0) { 371 PyInteger self = (PyInteger) gself; 372 PyObject ret = self.int___div__(arg0); 373 if (ret == null) 374 return Py.NotImplemented; 375 return ret; 376 } 377 378 } 379 dict.__setitem__("__div__", new PyMethodDescr("__div__", 380 PyInteger.class, 1, 1, new exposed___div__(null, null))); 381 class exposed___divmod__ extends PyBuiltinFunctionNarrow { 382 383 private PyInteger self; 384 385 public PyObject getSelf() { 386 return self; 387 } 388 389 exposed___divmod__(PyInteger self, PyBuiltinFunction.Info info) { 390 super(info); 391 this.self = self; 392 } 393 394 public PyBuiltinFunction makeBound(PyObject self) { 395 return new exposed___divmod__((PyInteger) self, info); 396 } 397 398 public PyObject __call__(PyObject arg0) { 399 PyObject ret = self.int___divmod__(arg0); 400 if (ret == null) 401 return Py.NotImplemented; 402 return ret; 403 } 404 405 public PyObject inst_call(PyObject gself, PyObject arg0) { 406 PyInteger self = (PyInteger) gself; 407 PyObject ret = self.int___divmod__(arg0); 408 if (ret == null) 409 return Py.NotImplemented; 410 return ret; 411 } 412 413 } 414 dict.__setitem__("__divmod__", new PyMethodDescr("__divmod__", 415 PyInteger.class, 1, 1, new exposed___divmod__(null, null))); 416 class exposed___floordiv__ extends PyBuiltinFunctionNarrow { 417 418 private PyInteger self; 419 420 public PyObject getSelf() { 421 return self; 422 } 423 424 exposed___floordiv__(PyInteger self, PyBuiltinFunction.Info info) { 425 super(info); 426 this.self = self; 427 } 428 429 public PyBuiltinFunction makeBound(PyObject self) { 430 return new exposed___floordiv__((PyInteger) self, info); 431 } 432 433 public PyObject __call__(PyObject arg0) { 434 PyObject ret = self.int___floordiv__(arg0); 435 if (ret == null) 436 return Py.NotImplemented; 437 return ret; 438 } 439 440 public PyObject inst_call(PyObject gself, PyObject arg0) { 441 PyInteger self = (PyInteger) gself; 442 PyObject ret = self.int___floordiv__(arg0); 443 if (ret == null) 444 return Py.NotImplemented; 445 return ret; 446 } 447 448 } 449 dict.__setitem__("__floordiv__", new PyMethodDescr("__floordiv__", 450 PyInteger.class, 1, 1, new exposed___floordiv__(null, null))); 451 class exposed___lshift__ extends PyBuiltinFunctionNarrow { 452 453 private PyInteger self; 454 455 public PyObject getSelf() { 456 return self; 457 } 458 459 exposed___lshift__(PyInteger self, PyBuiltinFunction.Info info) { 460 super(info); 461 this.self = self; 462 } 463 464 public PyBuiltinFunction makeBound(PyObject self) { 465 return new exposed___lshift__((PyInteger) self, info); 466 } 467 468 public PyObject __call__(PyObject arg0) { 469 PyObject ret = self.int___lshift__(arg0); 470 if (ret == null) 471 return Py.NotImplemented; 472 return ret; 473 } 474 475 public PyObject inst_call(PyObject gself, PyObject arg0) { 476 PyInteger self = (PyInteger) gself; 477 PyObject ret = self.int___lshift__(arg0); 478 if (ret == null) 479 return Py.NotImplemented; 480 return ret; 481 } 482 483 } 484 dict.__setitem__("__lshift__", new PyMethodDescr("__lshift__", 485 PyInteger.class, 1, 1, new exposed___lshift__(null, null))); 486 class exposed___mod__ extends PyBuiltinFunctionNarrow { 487 488 private PyInteger self; 489 490 public PyObject getSelf() { 491 return self; 492 } 493 494 exposed___mod__(PyInteger self, PyBuiltinFunction.Info info) { 495 super(info); 496 this.self = self; 497 } 498 499 public PyBuiltinFunction makeBound(PyObject self) { 500 return new exposed___mod__((PyInteger) self, info); 501 } 502 503 public PyObject __call__(PyObject arg0) { 504 PyObject ret = self.int___mod__(arg0); 505 if (ret == null) 506 return Py.NotImplemented; 507 return ret; 508 } 509 510 public PyObject inst_call(PyObject gself, PyObject arg0) { 511 PyInteger self = (PyInteger) gself; 512 PyObject ret = self.int___mod__(arg0); 513 if (ret == null) 514 return Py.NotImplemented; 515 return ret; 516 } 517 518 } 519 dict.__setitem__("__mod__", new PyMethodDescr("__mod__", 520 PyInteger.class, 1, 1, new exposed___mod__(null, null))); 521 class exposed___mul__ extends PyBuiltinFunctionNarrow { 522 523 private PyInteger self; 524 525 public PyObject getSelf() { 526 return self; 527 } 528 529 exposed___mul__(PyInteger self, PyBuiltinFunction.Info info) { 530 super(info); 531 this.self = self; 532 } 533 534 public PyBuiltinFunction makeBound(PyObject self) { 535 return new exposed___mul__((PyInteger) self, info); 536 } 537 538 public PyObject __call__(PyObject arg0) { 539 PyObject ret = self.int___mul__(arg0); 540 if (ret == null) 541 return Py.NotImplemented; 542 return ret; 543 } 544 545 public PyObject inst_call(PyObject gself, PyObject arg0) { 546 PyInteger self = (PyInteger) gself; 547 PyObject ret = self.int___mul__(arg0); 548 if (ret == null) 549 return Py.NotImplemented; 550 return ret; 551 } 552 553 } 554 dict.__setitem__("__mul__", new PyMethodDescr("__mul__", 555 PyInteger.class, 1, 1, new exposed___mul__(null, null))); 556 class exposed___or__ extends PyBuiltinFunctionNarrow { 557 558 private PyInteger self; 559 560 public PyObject getSelf() { 561 return self; 562 } 563 564 exposed___or__(PyInteger self, PyBuiltinFunction.Info info) { 565 super(info); 566 this.self = self; 567 } 568 569 public PyBuiltinFunction makeBound(PyObject self) { 570 return new exposed___or__((PyInteger) self, info); 571 } 572 573 public PyObject __call__(PyObject arg0) { 574 PyObject ret = self.int___or__(arg0); 575 if (ret == null) 576 return Py.NotImplemented; 577 return ret; 578 } 579 580 public PyObject inst_call(PyObject gself, PyObject arg0) { 581 PyInteger self = (PyInteger) gself; 582 PyObject ret = self.int___or__(arg0); 583 if (ret == null) 584 return Py.NotImplemented; 585 return ret; 586 } 587 588 } 589 dict.__setitem__("__or__", new PyMethodDescr("__or__", PyInteger.class, 590 1, 1, new exposed___or__(null, null))); 591 class exposed___radd__ extends PyBuiltinFunctionNarrow { 592 593 private PyInteger self; 594 595 public PyObject getSelf() { 596 return self; 597 } 598 599 exposed___radd__(PyInteger self, PyBuiltinFunction.Info info) { 600 super(info); 601 this.self = self; 602 } 603 604 public PyBuiltinFunction makeBound(PyObject self) { 605 return new exposed___radd__((PyInteger) self, info); 606 } 607 608 public PyObject __call__(PyObject arg0) { 609 PyObject ret = self.int___radd__(arg0); 610 if (ret == null) 611 return Py.NotImplemented; 612 return ret; 613 } 614 615 public PyObject inst_call(PyObject gself, PyObject arg0) { 616 PyInteger self = (PyInteger) gself; 617 PyObject ret = self.int___radd__(arg0); 618 if (ret == null) 619 return Py.NotImplemented; 620 return ret; 621 } 622 623 } 624 dict.__setitem__("__radd__", new PyMethodDescr("__radd__", 625 PyInteger.class, 1, 1, new exposed___radd__(null, null))); 626 class exposed___rdiv__ extends PyBuiltinFunctionNarrow { 627 628 private PyInteger self; 629 630 public PyObject getSelf() { 631 return self; 632 } 633 634 exposed___rdiv__(PyInteger self, PyBuiltinFunction.Info info) { 635 super(info); 636 this.self = self; 637 } 638 639 public PyBuiltinFunction makeBound(PyObject self) { 640 return new exposed___rdiv__((PyInteger) self, info); 641 } 642 643 public PyObject __call__(PyObject arg0) { 644 PyObject ret = self.int___rdiv__(arg0); 645 if (ret == null) 646 return Py.NotImplemented; 647 return ret; 648 } 649 650 public PyObject inst_call(PyObject gself, PyObject arg0) { 651 PyInteger self = (PyInteger) gself; 652 PyObject ret = self.int___rdiv__(arg0); 653 if (ret == null) 654 return Py.NotImplemented; 655 return ret; 656 } 657 658 } 659 dict.__setitem__("__rdiv__", new PyMethodDescr("__rdiv__", 660 PyInteger.class, 1, 1, new exposed___rdiv__(null, null))); 661 class exposed___rfloordiv__ extends PyBuiltinFunctionNarrow { 662 663 private PyInteger self; 664 665 public PyObject getSelf() { 666 return self; 667 } 668 669 exposed___rfloordiv__(PyInteger self, PyBuiltinFunction.Info info) { 670 super(info); 671 this.self = self; 672 } 673 674 public PyBuiltinFunction makeBound(PyObject self) { 675 return new exposed___rfloordiv__((PyInteger) self, info); 676 } 677 678 public PyObject __call__(PyObject arg0) { 679 PyObject ret = self.int___rfloordiv__(arg0); 680 if (ret == null) 681 return Py.NotImplemented; 682 return ret; 683 } 684 685 public PyObject inst_call(PyObject gself, PyObject arg0) { 686 PyInteger self = (PyInteger) gself; 687 PyObject ret = self.int___rfloordiv__(arg0); 688 if (ret == null) 689 return Py.NotImplemented; 690 return ret; 691 } 692 693 } 694 dict.__setitem__("__rfloordiv__", new PyMethodDescr("__rfloordiv__", 695 PyInteger.class, 1, 1, new exposed___rfloordiv__(null, null))); 696 class exposed___rmod__ extends PyBuiltinFunctionNarrow { 697 698 private PyInteger self; 699 700 public PyObject getSelf() { 701 return self; 702 } 703 704 exposed___rmod__(PyInteger self, PyBuiltinFunction.Info info) { 705 super(info); 706 this.self = self; 707 } 708 709 public PyBuiltinFunction makeBound(PyObject self) { 710 return new exposed___rmod__((PyInteger) self, info); 711 } 712 713 public PyObject __call__(PyObject arg0) { 714 PyObject ret = self.int___rmod__(arg0); 715 if (ret == null) 716 return Py.NotImplemented; 717 return ret; 718 } 719 720 public PyObject inst_call(PyObject gself, PyObject arg0) { 721 PyInteger self = (PyInteger) gself; 722 PyObject ret = self.int___rmod__(arg0); 723 if (ret == null) 724 return Py.NotImplemented; 725 return ret; 726 } 727 728 } 729 dict.__setitem__("__rmod__", new PyMethodDescr("__rmod__", 730 PyInteger.class, 1, 1, new exposed___rmod__(null, null))); 731 class exposed___rmul__ extends PyBuiltinFunctionNarrow { 732 733 private PyInteger self; 734 735 public PyObject getSelf() { 736 return self; 737 } 738 739 exposed___rmul__(PyInteger self, PyBuiltinFunction.Info info) { 740 super(info); 741 this.self = self; 742 } 743 744 public PyBuiltinFunction makeBound(PyObject self) { 745 return new exposed___rmul__((PyInteger) self, info); 746 } 747 748 public PyObject __call__(PyObject arg0) { 749 PyObject ret = self.int___rmul__(arg0); 750 if (ret == null) 751 return Py.NotImplemented; 752 return ret; 753 } 754 755 public PyObject inst_call(PyObject gself, PyObject arg0) { 756 PyInteger self = (PyInteger) gself; 757 PyObject ret = self.int___rmul__(arg0); 758 if (ret == null) 759 return Py.NotImplemented; 760 return ret; 761 } 762 763 } 764 dict.__setitem__("__rmul__", new PyMethodDescr("__rmul__", 765 PyInteger.class, 1, 1, new exposed___rmul__(null, null))); 766 class exposed___rshift__ extends PyBuiltinFunctionNarrow { 767 768 private PyInteger self; 769 770 public PyObject getSelf() { 771 return self; 772 } 773 774 exposed___rshift__(PyInteger self, PyBuiltinFunction.Info info) { 775 super(info); 776 this.self = self; 777 } 778 779 public PyBuiltinFunction makeBound(PyObject self) { 780 return new exposed___rshift__((PyInteger) self, info); 781 } 782 783 public PyObject __call__(PyObject arg0) { 784 PyObject ret = self.int___rshift__(arg0); 785 if (ret == null) 786 return Py.NotImplemented; 787 return ret; 788 } 789 790 public PyObject inst_call(PyObject gself, PyObject arg0) { 791 PyInteger self = (PyInteger) gself; 792 PyObject ret = self.int___rshift__(arg0); 793 if (ret == null) 794 return Py.NotImplemented; 795 return ret; 796 } 797 798 } 799 dict.__setitem__("__rshift__", new PyMethodDescr("__rshift__", 800 PyInteger.class, 1, 1, new exposed___rshift__(null, null))); 801 class exposed___rsub__ extends PyBuiltinFunctionNarrow { 802 803 private PyInteger self; 804 805 public PyObject getSelf() { 806 return self; 807 } 808 809 exposed___rsub__(PyInteger self, PyBuiltinFunction.Info info) { 810 super(info); 811 this.self = self; 812 } 813 814 public PyBuiltinFunction makeBound(PyObject self) { 815 return new exposed___rsub__((PyInteger) self, info); 816 } 817 818 public PyObject __call__(PyObject arg0) { 819 PyObject ret = self.int___rsub__(arg0); 820 if (ret == null) 821 return Py.NotImplemented; 822 return ret; 823 } 824 825 public PyObject inst_call(PyObject gself, PyObject arg0) { 826 PyInteger self = (PyInteger) gself; 827 PyObject ret = self.int___rsub__(arg0); 828 if (ret == null) 829 return Py.NotImplemented; 830 return ret; 831 } 832 833 } 834 dict.__setitem__("__rsub__", new PyMethodDescr("__rsub__", 835 PyInteger.class, 1, 1, new exposed___rsub__(null, null))); 836 class exposed___rtruediv__ extends PyBuiltinFunctionNarrow { 837 838 private PyInteger self; 839 840 public PyObject getSelf() { 841 return self; 842 } 843 844 exposed___rtruediv__(PyInteger self, PyBuiltinFunction.Info info) { 845 super(info); 846 this.self = self; 847 } 848 849 public PyBuiltinFunction makeBound(PyObject self) { 850 return new exposed___rtruediv__((PyInteger) self, info); 851 } 852 853 public PyObject __call__(PyObject arg0) { 854 PyObject ret = self.int___rtruediv__(arg0); 855 if (ret == null) 856 return Py.NotImplemented; 857 return ret; 858 } 859 860 public PyObject inst_call(PyObject gself, PyObject arg0) { 861 PyInteger self = (PyInteger) gself; 862 PyObject ret = self.int___rtruediv__(arg0); 863 if (ret == null) 864 return Py.NotImplemented; 865 return ret; 866 } 867 868 } 869 dict.__setitem__("__rtruediv__", new PyMethodDescr("__rtruediv__", 870 PyInteger.class, 1, 1, new exposed___rtruediv__(null, null))); 871 class exposed___sub__ extends PyBuiltinFunctionNarrow { 872 873 private PyInteger self; 874 875 public PyObject getSelf() { 876 return self; 877 } 878 879 exposed___sub__(PyInteger self, PyBuiltinFunction.Info info) { 880 super(info); 881 this.self = self; 882 } 883 884 public PyBuiltinFunction makeBound(PyObject self) { 885 return new exposed___sub__((PyInteger) self, info); 886 } 887 888 public PyObject __call__(PyObject arg0) { 889 PyObject ret = self.int___sub__(arg0); 890 if (ret == null) 891 return Py.NotImplemented; 892 return ret; 893 } 894 895 public PyObject inst_call(PyObject gself, PyObject arg0) { 896 PyInteger self = (PyInteger) gself; 897 PyObject ret = self.int___sub__(arg0); 898 if (ret == null) 899 return Py.NotImplemented; 900 return ret; 901 } 902 903 } 904 dict.__setitem__("__sub__", new PyMethodDescr("__sub__", 905 PyInteger.class, 1, 1, new exposed___sub__(null, null))); 906 class exposed___truediv__ extends PyBuiltinFunctionNarrow { 907 908 private PyInteger self; 909 910 public PyObject getSelf() { 911 return self; 912 } 913 914 exposed___truediv__(PyInteger self, PyBuiltinFunction.Info info) { 915 super(info); 916 this.self = self; 917 } 918 919 public PyBuiltinFunction makeBound(PyObject self) { 920 return new exposed___truediv__((PyInteger) self, info); 921 } 922 923 public PyObject __call__(PyObject arg0) { 924 PyObject ret = self.int___truediv__(arg0); 925 if (ret == null) 926 return Py.NotImplemented; 927 return ret; 928 } 929 930 public PyObject inst_call(PyObject gself, PyObject arg0) { 931 PyInteger self = (PyInteger) gself; 932 PyObject ret = self.int___truediv__(arg0); 933 if (ret == null) 934 return Py.NotImplemented; 935 return ret; 936 } 937 938 } 939 dict.__setitem__("__truediv__", new PyMethodDescr("__truediv__", 940 PyInteger.class, 1, 1, new exposed___truediv__(null, null))); 941 class exposed___xor__ extends PyBuiltinFunctionNarrow { 942 943 private PyInteger self; 944 945 public PyObject getSelf() { 946 return self; 947 } 948 949 exposed___xor__(PyInteger self, PyBuiltinFunction.Info info) { 950 super(info); 951 this.self = self; 952 } 953 954 public PyBuiltinFunction makeBound(PyObject self) { 955 return new exposed___xor__((PyInteger) self, info); 956 } 957 958 public PyObject __call__(PyObject arg0) { 959 PyObject ret = self.int___xor__(arg0); 960 if (ret == null) 961 return Py.NotImplemented; 962 return ret; 963 } 964 965 public PyObject inst_call(PyObject gself, PyObject arg0) { 966 PyInteger self = (PyInteger) gself; 967 PyObject ret = self.int___xor__(arg0); 968 if (ret == null) 969 return Py.NotImplemented; 970 return ret; 971 } 972 973 } 974 dict.__setitem__("__xor__", new PyMethodDescr("__xor__", 975 PyInteger.class, 1, 1, new exposed___xor__(null, null))); 976 class exposed___cmp__ extends PyBuiltinFunctionNarrow { 977 978 private PyInteger self; 979 980 public PyObject getSelf() { 981 return self; 982 } 983 984 exposed___cmp__(PyInteger self, PyBuiltinFunction.Info info) { 985 super(info); 986 this.self = self; 987 } 988 989 public PyBuiltinFunction makeBound(PyObject self) { 990 return new exposed___cmp__((PyInteger) self, info); 991 } 992 993 public PyObject __call__(PyObject arg0) { 994 int ret = self.int___cmp__(arg0); 995 if (ret == -2) { 996 throw Py.TypeError("int" 997 + ".__cmp__(x,y) requires y to be '" + "int" 998 + "', not a '" + (arg0).getType().fastGetName() 999 + "'"); 1000 } 1001 return Py.newInteger(ret); 1002 } 1003 1004 public PyObject inst_call(PyObject gself, PyObject arg0) { 1005 PyInteger self = (PyInteger) gself; 1006 int ret = self.int___cmp__(arg0); 1007 if (ret == -2) { 1008 throw Py.TypeError("int" 1009 + ".__cmp__(x,y) requires y to be '" + "int" 1010 + "', not a '" + (arg0).getType().fastGetName() 1011 + "'"); 1012 } 1013 return Py.newInteger(ret); 1014 } 1015 1016 } 1017 dict.__setitem__("__cmp__", new PyMethodDescr("__cmp__", 1018 PyInteger.class, 1, 1, new exposed___cmp__(null, null))); 1019 class exposed___pow__ extends PyBuiltinFunctionNarrow { 1020 1021 private PyInteger self; 1022 1023 public PyObject getSelf() { 1024 return self; 1025 } 1026 1027 exposed___pow__(PyInteger self, PyBuiltinFunction.Info info) { 1028 super(info); 1029 this.self = self; 1030 } 1031 1032 public PyBuiltinFunction makeBound(PyObject self) { 1033 return new exposed___pow__((PyInteger) self, info); 1034 } 1035 1036 public PyObject __call__(PyObject arg0, PyObject arg1) { 1037 PyObject ret = self.int___pow__(arg0, arg1); 1038 if (ret == null) 1039 return Py.NotImplemented; 1040 return ret; 1041 } 1042 1043 public PyObject inst_call(PyObject gself, PyObject arg0, 1044 PyObject arg1) { 1045 PyInteger self = (PyInteger) gself; 1046 PyObject ret = self.int___pow__(arg0, arg1); 1047 if (ret == null) 1048 return Py.NotImplemented; 1049 return ret; 1050 } 1051 1052 public PyObject __call__(PyObject arg0) { 1053 PyObject ret = self.int___pow__(arg0, null); 1054 if (ret == null) 1055 return Py.NotImplemented; 1056 return ret; 1057 } 1058 1059 public PyObject inst_call(PyObject gself, PyObject arg0) { 1060 PyInteger self = (PyInteger) gself; 1061 PyObject ret = self.int___pow__(arg0, null); 1062 if (ret == null) 1063 return Py.NotImplemented; 1064 return ret; 1065 } 1066 1067 } 1068 dict.__setitem__("__pow__", new PyMethodDescr("__pow__", 1069 PyInteger.class, 1, 2, new exposed___pow__(null, null))); 1070 class exposed___nonzero__ extends PyBuiltinFunctionNarrow { 1071 1072 private PyInteger self; 1073 1074 public PyObject getSelf() { 1075 return self; 1076 } 1077 1078 exposed___nonzero__(PyInteger self, PyBuiltinFunction.Info info) { 1079 super(info); 1080 this.self = self; 1081 } 1082 1083 public PyBuiltinFunction makeBound(PyObject self) { 1084 return new exposed___nonzero__((PyInteger) self, info); 1085 } 1086 1087 public PyObject __call__() { 1088 return Py.newBoolean(self.int___nonzero__()); 1089 } 1090 1091 public PyObject inst_call(PyObject gself) { 1092 PyInteger self = (PyInteger) gself; 1093 return Py.newBoolean(self.int___nonzero__()); 1094 } 1095 1096 } 1097 dict.__setitem__("__nonzero__", new PyMethodDescr("__nonzero__", 1098 PyInteger.class, 0, 0, new exposed___nonzero__(null, null))); 1099 class exposed___repr__ extends PyBuiltinFunctionNarrow { 1100 1101 private PyInteger self; 1102 1103 public PyObject getSelf() { 1104 return self; 1105 } 1106 1107 exposed___repr__(PyInteger self, PyBuiltinFunction.Info info) { 1108 super(info); 1109 this.self = self; 1110 } 1111 1112 public PyBuiltinFunction makeBound(PyObject self) { 1113 return new exposed___repr__((PyInteger) self, info); 1114 } 1115 1116 public PyObject __call__() { 1117 return new PyString(self.int_toString()); 1118 } 1119 1120 public PyObject inst_call(PyObject gself) { 1121 PyInteger self = (PyInteger) gself; 1122 return new PyString(self.int_toString()); 1123 } 1124 1125 } 1126 dict.__setitem__("__repr__", new PyMethodDescr("__repr__", 1127 PyInteger.class, 0, 0, new exposed___repr__(null, null))); 1128 class exposed___str__ extends PyBuiltinFunctionNarrow { 1129 1130 private PyInteger self; 1131 1132 public PyObject getSelf() { 1133 return self; 1134 } 1135 1136 exposed___str__(PyInteger self, PyBuiltinFunction.Info info) { 1137 super(info); 1138 this.self = self; 1139 } 1140 1141 public PyBuiltinFunction makeBound(PyObject self) { 1142 return new exposed___str__((PyInteger) self, info); 1143 } 1144 1145 public PyObject __call__() { 1146 return new PyString(self.int_toString()); 1147 } 1148 1149 public PyObject inst_call(PyObject gself) { 1150 PyInteger self = (PyInteger) gself; 1151 return new PyString(self.int_toString()); 1152 } 1153 1154 } 1155 dict.__setitem__("__str__", new PyMethodDescr("__str__", 1156 PyInteger.class, 0, 0, new exposed___str__(null, null))); 1157 class exposed___hash__ extends PyBuiltinFunctionNarrow { 1158 1159 private PyInteger self; 1160 1161 public PyObject getSelf() { 1162 return self; 1163 } 1164 1165 exposed___hash__(PyInteger self, PyBuiltinFunction.Info info) { 1166 super(info); 1167 this.self = self; 1168 } 1169 1170 public PyBuiltinFunction makeBound(PyObject self) { 1171 return new exposed___hash__((PyInteger) self, info); 1172 } 1173 1174 public PyObject __call__() { 1175 return Py.newInteger(self.int_hashCode()); 1176 } 1177 1178 public PyObject inst_call(PyObject gself) { 1179 PyInteger self = (PyInteger) gself; 1180 return Py.newInteger(self.int_hashCode()); 1181 } 1182 1183 } 1184 dict.__setitem__("__hash__", new PyMethodDescr("__hash__", 1185 PyInteger.class, 0, 0, new exposed___hash__(null, null))); 1186 dict.__setitem__("__new__", new PyNewWrapper(PyInteger.class, 1187 "__new__", -1, -1) { 1188 1189 public PyObject new_impl(boolean init, PyType subtype, 1190 PyObject[] args, String [] keywords) { 1191 return int_new(this, init, subtype, args, keywords); 1192 } 1193 1194 }); 1195 } 1196 1197 public static PyObject int_new(PyObject new_, boolean init, PyType subtype, 1198 PyObject[] args, String [] keywords) { 1199 ArgParser ap = new ArgParser("int", args, keywords, new String [] { "x", 1200 "base" }, 0); 1201 PyObject x = ap.getPyObject(0, null); 1202 int base = ap.getInt(1, -909); 1203 if (x == null) 1204 return Py.Zero; 1205 if (base == -909) { 1206 return x.__int__(); 1207 } 1208 if (!(x instanceof PyString)) { 1209 throw Py 1210 .TypeError("int: can't convert non-string with explicit base"); 1211 } 1212 return Py.newInteger(((PyString) x).atoi(base)); 1213 } 1215 private static final PyType INTTYPE = PyType.fromClass(PyInteger.class); 1216 1217 private int value; 1218 1219 public PyInteger(int v) { 1220 super(INTTYPE); 1221 value = (int)v; 1222 } 1223 1224 public int getValue() { 1225 return value; 1226 } 1227 1228 public String safeRepr() throws PyIgnoreMethodTag { 1229 return "'int' object"; 1230 } 1231 1232 public String toString() { 1233 return int_toString(); 1234 } 1235 1236 final String int_toString() { 1237 return Integer.toString(value); 1238 } 1239 1240 public int hashCode() { 1241 return int_hashCode(); 1242 } 1243 1244 final int int_hashCode() { 1245 return value; 1246 } 1247 1248 private static void err_ovf(String msg) { 1249 try { 1250 Py.OverflowWarning(msg); 1251 } catch (PyException exc) { 1252 if (Py.matchException(exc, Py.OverflowWarning)) 1253 throw Py.OverflowError(msg); 1254 } 1255 } 1256 1257 public boolean __nonzero__() { 1258 return int___nonzero__(); 1259 } 1260 1261 final boolean int___nonzero__() { 1262 return value != 0; 1263 } 1264 1265 public Object __tojava__(Class c) { 1266 if (c == Integer.TYPE || c == Number .class || 1267 c == Object .class || c == Integer .class || 1268 c == Serializable .class) 1269 { 1270 return new Integer (value); 1271 } 1272 1273 if (c == Boolean.TYPE || c == Boolean .class) 1274 return new Boolean (value != 0); 1275 if (c == Byte.TYPE || c == Byte .class) 1276 return new Byte ((byte)value); 1277 if (c == Short.TYPE || c == Short .class) 1278 return new Short ((short)value); 1279 1280 if (c == Long.TYPE || c == Long .class) 1281 return new Long (value); 1282 if (c == Float.TYPE || c == Float .class) 1283 return new Float (value); 1284 if (c == Double.TYPE || c == Double .class) 1285 return new Double (value); 1286 return super.__tojava__(c); 1287 } 1288 1289 public int __cmp__(PyObject other) { 1290 return int___cmp__(other); 1291 } 1292 1293 final int int___cmp__(PyObject other) { 1294 if (!canCoerce(other)) 1295 return -2; 1296 int v = coerce(other); 1297 return value < v ? -1 : value > v ? 1 : 0; 1298 } 1299 1300 public Object __coerce_ex__(PyObject other) { 1301 if (other instanceof PyInteger) 1302 return other; 1303 else 1304 return Py.None; 1305 } 1306 1307 private static final boolean canCoerce(PyObject other) { 1308 return other instanceof PyInteger; 1309 } 1310 1311 private static final int coerce(PyObject other) { 1312 if (other instanceof PyInteger) 1313 return ((PyInteger) other).value; 1314 else 1315 throw Py.TypeError("xxx"); 1316 } 1317 1318 1319 public PyObject __add__(PyObject right) { 1320 return int___add__(right); 1321 } 1322 1323 final PyObject int___add__(PyObject right) { 1324 if (!canCoerce(right)) 1325 return null; 1326 int rightv = coerce(right); 1327 int a = value; 1328 int b = rightv; 1329 int x = a + b; 1330 if ((x^a) >= 0 || (x^b) >= 0) 1331 return Py.newInteger(x); 1332 err_ovf("integer addition"); 1333 return new PyLong((long) a + (long)b); 1334 } 1335 1336 public PyObject __radd__(PyObject left) { 1337 return int___radd__(left); 1338 } 1339 1340 final PyObject int___radd__(PyObject left) { 1341 return __add__(left); 1342 } 1343 1344 private static PyObject _sub(int a, int b) { 1345 int x = a - b; 1346 if ((x^a) >= 0 || (x^~b) >= 0) 1347 return Py.newInteger(x); 1348 err_ovf("integer subtraction"); 1349 return new PyLong((long) a - (long)b); 1350 } 1351 1352 public PyObject __sub__(PyObject right) { 1353 return int___sub__(right); 1354 } 1355 1356 final PyObject int___sub__(PyObject right) { 1357 if (!canCoerce(right)) 1358 return null; 1359 return _sub(value, coerce(right)); 1360 } 1361 1362 public PyObject __rsub__(PyObject left) { 1363 return int___rsub__(left); 1364 } 1365 1366 final PyObject int___rsub__(PyObject left) { 1367 if (!canCoerce(left)) 1368 return null; 1369 return _sub(coerce(left), value); 1370 } 1371 1372 public PyObject __mul__(PyObject right) { 1373 return int___mul__(right); 1374 } 1375 1376 final PyObject int___mul__(PyObject right) { 1377 if (right instanceof PySequence) 1378 return ((PySequence) right).repeat(value); 1379 1380 if (!canCoerce(right)) 1381 return null; 1382 int rightv = coerce(right); 1383 1384 double x = (double)value; 1385 x *= rightv; 1386 1389 if (x <= Integer.MAX_VALUE && x >= Integer.MIN_VALUE) 1390 return Py.newInteger((int)x); 1391 err_ovf("integer multiplication"); 1392 return __long__().__mul__(right); 1393 } 1394 1395 public PyObject __rmul__(PyObject left) { 1396 return int___rmul__(left); 1397 } 1398 1399 final PyObject int___rmul__(PyObject left) { 1400 return __mul__(left); 1401 } 1402 1403 private static int divide(int x, int y) { 1406 if (y == 0) 1407 throw Py.ZeroDivisionError("integer division or modulo by zero"); 1408 1409 if (y == -1 && x < 0 && x == -x) { 1410 err_ovf("integer division: "+x+" + "+y); 1411 } 1412 int xdivy = x / y; 1413 int xmody = x - xdivy * y; 1414 1419 if (xmody != 0 && ((y ^ xmody) < 0) ) { 1420 xmody += y; 1421 --xdivy; 1422 } 1424 return xdivy; 1425 } 1426 1427 public PyObject __div__(PyObject right) { 1428 return int___div__(right); 1429 } 1430 1431 final PyObject int___div__(PyObject right) { 1432 if (!canCoerce(right)) 1433 return null; 1434 if (Options.divisionWarning > 0) 1435 Py.warning(Py.DeprecationWarning, "classic int division"); 1436 return Py.newInteger(divide(value, coerce(right))); 1437 } 1438 1439 public PyObject __rdiv__(PyObject left) { 1440 return int___rdiv__(left); 1441 } 1442 1443 final PyObject int___rdiv__(PyObject left) { 1444 if (!canCoerce(left)) 1445 return null; 1446 if (Options.divisionWarning > 0) 1447 Py.warning(Py.DeprecationWarning, "classic int division"); 1448 return Py.newInteger(divide(coerce(left), value)); 1449 } 1450 1451 public PyObject __floordiv__(PyObject right) { 1452 return int___floordiv__(right); 1453 } 1454 1455 final PyObject int___floordiv__(PyObject right) { 1456 if (!canCoerce(right)) 1457 return null; 1458 return Py.newInteger(divide(value, coerce(right))); 1459 } 1460 1461 public PyObject __rfloordiv__(PyObject left) { 1462 return int___rfloordiv__(left); 1463 } 1464 1465 final PyObject int___rfloordiv__(PyObject left) { 1466 if (!canCoerce(left)) 1467 return null; 1468 return Py.newInteger(divide(coerce(left), value)); 1469 } 1470 1471 public PyObject __truediv__(PyObject right) { 1472 return int___truediv__(right); 1473 } 1474 1475 final PyObject int___truediv__(PyObject right) { 1476 if (right instanceof PyInteger) 1477 return __float__().__truediv__(right); 1478 return null; 1479 } 1480 1481 public PyObject __rtruediv__(PyObject left) { 1482 return int___rtruediv__(left); 1483 } 1484 1485 final PyObject int___rtruediv__(PyObject left) { 1486 if (left instanceof PyInteger) 1487 return left.__float__().__truediv__(this); 1488 return null; 1489 } 1490 1491 private static int modulo(int x, int y, int xdivy) { 1492 return x - xdivy*y; 1493 } 1494 1495 public PyObject __mod__(PyObject right) { 1496 return int___mod__(right); 1497 } 1498 1499 final PyObject int___mod__(PyObject right) { 1500 if (!canCoerce(right)) 1501 return null; 1502 int rightv = coerce(right); 1503 return Py.newInteger(modulo(value, rightv, divide(value, rightv))); 1504 } 1505 1506 public PyObject __rmod__(PyObject left) { 1507 return int___rmod__(left); 1508 } 1509 1510 final PyObject int___rmod__(PyObject left) { 1511 if (!canCoerce(left)) 1512 return null; 1513 int leftv = coerce(left); 1514 return Py.newInteger(modulo(leftv, value, divide(leftv, value))); 1515 } 1516 1517 public PyObject __divmod__(PyObject right) { 1518 return int___divmod__(right); 1519 } 1520 1521 final PyObject int___divmod__(PyObject right) { 1522 if (!canCoerce(right)) 1523 return null; 1524 int rightv = coerce(right); 1525 1526 int xdivy = divide(value, rightv); 1527 return new PyTuple(new PyObject[] { 1528 new PyInteger(xdivy), 1529 new PyInteger(modulo(value, rightv, xdivy)) 1530 }); 1531 } 1532 1533 public PyObject __pow__(PyObject right, PyObject modulo) { 1534 return int___pow__(right,modulo); 1535 } 1536 1537 final PyObject int___pow__(PyObject right, PyObject modulo) { 1538 if (!canCoerce(right)) 1539 return null; 1540 1541 if (modulo != null && !canCoerce(modulo)) 1542 return null; 1543 1544 return _pow(value, coerce(right), modulo, this, right); 1545 } 1546 1547 public PyObject __rpow__(PyObject left, PyObject modulo) { 1548 if (!canCoerce(left)) 1549 return null; 1550 1551 if (modulo != null && !canCoerce(modulo)) 1552 return null; 1553 1554 return _pow(coerce(left), value, modulo, left, this); 1555 } 1556 1557 private static PyObject _pow(int value, int pow, PyObject modulo, 1558 PyObject left, PyObject right) { 1559 int mod = 0; 1560 long tmp = value; 1561 boolean neg = false; 1562 if (tmp < 0) { 1563 tmp = -tmp; 1564 neg = (pow & 0x1) != 0; 1565 } 1566 long result = 1; 1567 1568 if (pow < 0) { 1569 if (value != 0) 1570 return left.__float__().__pow__(right, modulo); 1571 else 1572 throw Py.ZeroDivisionError("cannot raise 0 to a " + 1573 "negative power"); 1574 } 1575 1576 if (modulo != null) { 1577 mod = coerce(modulo); 1578 if (mod == 0) { 1579 throw Py.ValueError("pow(x, y, z) with z==0"); 1580 } 1581 } 1582 1583 while (pow > 0) { 1585 if ((pow & 0x1) != 0) { 1586 result *= tmp; 1587 if (mod != 0) { 1588 result %= (long)mod; 1589 } 1590 1591 if (result > Integer.MAX_VALUE) { 1592 err_ovf("integer exponentiation"); 1593 return left.__long__().__pow__(right, modulo); 1594 } 1595 } 1596 pow >>= 1; 1597 if (pow == 0) 1598 break; 1599 tmp *= tmp; 1600 1601 if (mod != 0) { 1602 tmp %= (long)mod; 1603 } 1604 1605 if (tmp > Integer.MAX_VALUE) { 1606 err_ovf("integer exponentiation"); 1607 return left.__long__().__pow__(right, modulo); 1608 } 1609 } 1610 1611 int ret = (int)result; 1612 if (neg) 1613 ret = -ret; 1614 1615 if (mod != 0) { 1617 ret = modulo(ret, mod, divide(ret, mod)); 1618 } 1619 return Py.newInteger(ret); 1620 } 1621 1622 public PyObject __lshift__(PyObject right) { 1623 return int___lshift__(right); 1624 } 1625 1626 final PyObject int___lshift__(PyObject right) { 1627 int rightv; 1628 if (right instanceof PyInteger) 1629 rightv = ((PyInteger)right).value; 1630 else 1631 return null; 1632 1633 if (rightv > 31) 1634 return new PyInteger(0); 1635 else if(rightv < 0) 1636 throw Py.ValueError("negative shift count"); 1637 return Py.newInteger(value << rightv); 1638 } 1639 1640 public PyObject __rshift__(PyObject right) { 1641 return int___rshift__(right); 1642 } 1643 1644 final PyObject int___rshift__(PyObject right) { 1645 int rightv; 1646 if (right instanceof PyInteger) 1647 rightv = ((PyInteger)right).value; 1648 else 1649 return null; 1650 1651 if(rightv < 0) 1652 throw Py.ValueError("negative shift count"); 1653 1654 return Py.newInteger(value >> rightv); 1655 } 1656 1657 public PyObject __and__(PyObject right) { 1658 return int___and__(right); 1659 } 1660 1661 final PyObject int___and__(PyObject right) { 1662 int rightv; 1663 if (right instanceof PyInteger) 1664 rightv = ((PyInteger)right).value; 1665 else 1666 return null; 1667 1668 return Py.newInteger(value & rightv); 1669 } 1670 1671 public PyObject __xor__(PyObject right) { 1672 return int___xor__(right); 1673 } 1674 1675 final PyObject int___xor__(PyObject right) { 1676 int rightv; 1677 if (right instanceof PyInteger) 1678 rightv = ((PyInteger)right).value; 1679 else 1680 return null; 1681 1682 return Py.newInteger(value ^ rightv); 1683 } 1684 1685 public PyObject __or__(PyObject right) { 1686 return int___or__(right); 1687 } 1688 1689 final PyObject int___or__(PyObject right) { 1690 int rightv; 1691 if (right instanceof PyInteger) 1692 rightv = ((PyInteger)right).value; 1693 else 1694 return null; 1695 1696 return Py.newInteger(value | rightv); 1697 } 1698 1699 public PyObject __neg__() { 1700 return int___neg__(); 1701 } 1702 1703 final PyObject int___neg__() { 1704 int x = -value; 1705 if (value < 0 && x < 0) 1706 err_ovf("integer negation"); 1707 return Py.newInteger(x); 1708 } 1709 1710 public PyObject __pos__() { 1711 return int___pos__(); 1712 } 1713 1714 final PyObject int___pos__() { 1715 return this; 1716 } 1717 1718 public PyObject __abs__() { 1719 return int___abs__(); 1720 } 1721 1722 final PyObject int___abs__() { 1723 if (value >= 0) 1724 return this; 1725 else 1726 return __neg__(); 1727 } 1728 1729 public PyObject __invert__() { 1730 return int___invert__(); 1731 } 1732 1733 final PyObject int___invert__() { 1734 return Py.newInteger(~value); 1735 } 1736 1737 public PyObject __int__() { 1738 return int___int__(); 1739 } 1740 1741 final PyInteger int___int__() { 1742 return this; 1743 } 1744 1745 public PyLong __long__() { 1746 return int___long__(); 1747 } 1748 1749 final PyLong int___long__() { 1750 return new PyLong(value); 1751 } 1752 1753 public PyFloat __float__() { 1754 return int___float__(); 1755 } 1756 1757 final PyFloat int___float__() { 1758 return new PyFloat((double)value); 1759 } 1760 1761 public PyComplex __complex__() { 1762 return new PyComplex((double)value, 0.); 1763 } 1764 1765 public PyString __oct__() { 1766 return int___oct__(); 1767 } 1768 1769 final PyString int___oct__() { 1770 if (value < 0) { 1771 return new PyString( 1772 "0"+Long.toString(0x100000000l+(long)value, 8)); 1773 } else if (value > 0) { 1774 return new PyString("0"+Integer.toString(value, 8)); 1775 } else 1776 return new PyString("0"); 1777 } 1778 1779 public PyString __hex__() { 1780 return int___hex__(); 1781 } 1782 1783 final PyString int___hex__() { 1784 if (value < 0) { 1785 return new PyString( 1786 "0x"+Long.toString(0x100000000l+(long)value, 16)); 1787 } else { 1788 return new PyString("0x"+Integer.toString(value, 16)); 1789 } 1790 } 1791 1792 public boolean isMappingType() { return false; } 1793 public boolean isSequenceType() { return false; } 1794 1795 public long asLong(int index) throws PyObject.ConversionException { 1796 return getValue(); 1797 } 1798 1799 public int asInt(int index) throws PyObject.ConversionException { 1800 return getValue(); 1801 } 1802} 1803 | Popular Tags |