1 package org.python.core; 3 4 import java.io.Serializable ; 5 6 9 10 public class PyFloat extends PyObject 11 { 12 13 14 public static final String exposed_name="float"; 15 16 public static void typeSetup(PyObject dict,PyType.Newstyle marker) { 17 class exposed___abs__ extends PyBuiltinFunctionNarrow { 18 19 private PyFloat self; 20 21 public PyObject getSelf() { 22 return self; 23 } 24 25 exposed___abs__(PyFloat self,PyBuiltinFunction.Info info) { 26 super(info); 27 this.self=self; 28 } 29 30 public PyBuiltinFunction makeBound(PyObject self) { 31 return new exposed___abs__((PyFloat)self,info); 32 } 33 34 public PyObject __call__() { 35 return self.float___abs__(); 36 } 37 38 public PyObject inst_call(PyObject gself) { 39 PyFloat self=(PyFloat)gself; 40 return self.float___abs__(); 41 } 42 43 } 44 dict.__setitem__("__abs__",new PyMethodDescr("__abs__",PyFloat.class,0,0,new exposed___abs__(null,null))); 45 class exposed___float__ extends PyBuiltinFunctionNarrow { 46 47 private PyFloat self; 48 49 public PyObject getSelf() { 50 return self; 51 } 52 53 exposed___float__(PyFloat self,PyBuiltinFunction.Info info) { 54 super(info); 55 this.self=self; 56 } 57 58 public PyBuiltinFunction makeBound(PyObject self) { 59 return new exposed___float__((PyFloat)self,info); 60 } 61 62 public PyObject __call__() { 63 return self.float___float__(); 64 } 65 66 public PyObject inst_call(PyObject gself) { 67 PyFloat self=(PyFloat)gself; 68 return self.float___float__(); 69 } 70 71 } 72 dict.__setitem__("__float__",new PyMethodDescr("__float__",PyFloat.class,0,0,new exposed___float__(null,null))); 73 class exposed___int__ extends PyBuiltinFunctionNarrow { 74 75 private PyFloat self; 76 77 public PyObject getSelf() { 78 return self; 79 } 80 81 exposed___int__(PyFloat self,PyBuiltinFunction.Info info) { 82 super(info); 83 this.self=self; 84 } 85 86 public PyBuiltinFunction makeBound(PyObject self) { 87 return new exposed___int__((PyFloat)self,info); 88 } 89 90 public PyObject __call__() { 91 return self.float___int__(); 92 } 93 94 public PyObject inst_call(PyObject gself) { 95 PyFloat self=(PyFloat)gself; 96 return self.float___int__(); 97 } 98 99 } 100 dict.__setitem__("__int__",new PyMethodDescr("__int__",PyFloat.class,0,0,new exposed___int__(null,null))); 101 class exposed___long__ extends PyBuiltinFunctionNarrow { 102 103 private PyFloat self; 104 105 public PyObject getSelf() { 106 return self; 107 } 108 109 exposed___long__(PyFloat self,PyBuiltinFunction.Info info) { 110 super(info); 111 this.self=self; 112 } 113 114 public PyBuiltinFunction makeBound(PyObject self) { 115 return new exposed___long__((PyFloat)self,info); 116 } 117 118 public PyObject __call__() { 119 return self.float___long__(); 120 } 121 122 public PyObject inst_call(PyObject gself) { 123 PyFloat self=(PyFloat)gself; 124 return self.float___long__(); 125 } 126 127 } 128 dict.__setitem__("__long__",new PyMethodDescr("__long__",PyFloat.class,0,0,new exposed___long__(null,null))); 129 class exposed___neg__ extends PyBuiltinFunctionNarrow { 130 131 private PyFloat self; 132 133 public PyObject getSelf() { 134 return self; 135 } 136 137 exposed___neg__(PyFloat self,PyBuiltinFunction.Info info) { 138 super(info); 139 this.self=self; 140 } 141 142 public PyBuiltinFunction makeBound(PyObject self) { 143 return new exposed___neg__((PyFloat)self,info); 144 } 145 146 public PyObject __call__() { 147 return self.float___neg__(); 148 } 149 150 public PyObject inst_call(PyObject gself) { 151 PyFloat self=(PyFloat)gself; 152 return self.float___neg__(); 153 } 154 155 } 156 dict.__setitem__("__neg__",new PyMethodDescr("__neg__",PyFloat.class,0,0,new exposed___neg__(null,null))); 157 class exposed___pos__ extends PyBuiltinFunctionNarrow { 158 159 private PyFloat self; 160 161 public PyObject getSelf() { 162 return self; 163 } 164 165 exposed___pos__(PyFloat self,PyBuiltinFunction.Info info) { 166 super(info); 167 this.self=self; 168 } 169 170 public PyBuiltinFunction makeBound(PyObject self) { 171 return new exposed___pos__((PyFloat)self,info); 172 } 173 174 public PyObject __call__() { 175 return self.float___pos__(); 176 } 177 178 public PyObject inst_call(PyObject gself) { 179 PyFloat self=(PyFloat)gself; 180 return self.float___pos__(); 181 } 182 183 } 184 dict.__setitem__("__pos__",new PyMethodDescr("__pos__",PyFloat.class,0,0,new exposed___pos__(null,null))); 185 class exposed___add__ extends PyBuiltinFunctionNarrow { 186 187 private PyFloat self; 188 189 public PyObject getSelf() { 190 return self; 191 } 192 193 exposed___add__(PyFloat self,PyBuiltinFunction.Info info) { 194 super(info); 195 this.self=self; 196 } 197 198 public PyBuiltinFunction makeBound(PyObject self) { 199 return new exposed___add__((PyFloat)self,info); 200 } 201 202 public PyObject __call__(PyObject arg0) { 203 PyObject ret=self.float___add__(arg0); 204 if (ret==null) 205 return Py.NotImplemented; 206 return ret; 207 } 208 209 public PyObject inst_call(PyObject gself,PyObject arg0) { 210 PyFloat self=(PyFloat)gself; 211 PyObject ret=self.float___add__(arg0); 212 if (ret==null) 213 return Py.NotImplemented; 214 return ret; 215 } 216 217 } 218 dict.__setitem__("__add__",new PyMethodDescr("__add__",PyFloat.class,1,1,new exposed___add__(null,null))); 219 class exposed___div__ extends PyBuiltinFunctionNarrow { 220 221 private PyFloat self; 222 223 public PyObject getSelf() { 224 return self; 225 } 226 227 exposed___div__(PyFloat self,PyBuiltinFunction.Info info) { 228 super(info); 229 this.self=self; 230 } 231 232 public PyBuiltinFunction makeBound(PyObject self) { 233 return new exposed___div__((PyFloat)self,info); 234 } 235 236 public PyObject __call__(PyObject arg0) { 237 PyObject ret=self.float___div__(arg0); 238 if (ret==null) 239 return Py.NotImplemented; 240 return ret; 241 } 242 243 public PyObject inst_call(PyObject gself,PyObject arg0) { 244 PyFloat self=(PyFloat)gself; 245 PyObject ret=self.float___div__(arg0); 246 if (ret==null) 247 return Py.NotImplemented; 248 return ret; 249 } 250 251 } 252 dict.__setitem__("__div__",new PyMethodDescr("__div__",PyFloat.class,1,1,new exposed___div__(null,null))); 253 class exposed___divmod__ extends PyBuiltinFunctionNarrow { 254 255 private PyFloat self; 256 257 public PyObject getSelf() { 258 return self; 259 } 260 261 exposed___divmod__(PyFloat self,PyBuiltinFunction.Info info) { 262 super(info); 263 this.self=self; 264 } 265 266 public PyBuiltinFunction makeBound(PyObject self) { 267 return new exposed___divmod__((PyFloat)self,info); 268 } 269 270 public PyObject __call__(PyObject arg0) { 271 PyObject ret=self.float___divmod__(arg0); 272 if (ret==null) 273 return Py.NotImplemented; 274 return ret; 275 } 276 277 public PyObject inst_call(PyObject gself,PyObject arg0) { 278 PyFloat self=(PyFloat)gself; 279 PyObject ret=self.float___divmod__(arg0); 280 if (ret==null) 281 return Py.NotImplemented; 282 return ret; 283 } 284 285 } 286 dict.__setitem__("__divmod__",new PyMethodDescr("__divmod__",PyFloat.class,1,1,new exposed___divmod__(null,null))); 287 class exposed___floordiv__ extends PyBuiltinFunctionNarrow { 288 289 private PyFloat self; 290 291 public PyObject getSelf() { 292 return self; 293 } 294 295 exposed___floordiv__(PyFloat self,PyBuiltinFunction.Info info) { 296 super(info); 297 this.self=self; 298 } 299 300 public PyBuiltinFunction makeBound(PyObject self) { 301 return new exposed___floordiv__((PyFloat)self,info); 302 } 303 304 public PyObject __call__(PyObject arg0) { 305 PyObject ret=self.float___floordiv__(arg0); 306 if (ret==null) 307 return Py.NotImplemented; 308 return ret; 309 } 310 311 public PyObject inst_call(PyObject gself,PyObject arg0) { 312 PyFloat self=(PyFloat)gself; 313 PyObject ret=self.float___floordiv__(arg0); 314 if (ret==null) 315 return Py.NotImplemented; 316 return ret; 317 } 318 319 } 320 dict.__setitem__("__floordiv__",new PyMethodDescr("__floordiv__",PyFloat.class,1,1,new exposed___floordiv__(null,null))); 321 class exposed___mod__ extends PyBuiltinFunctionNarrow { 322 323 private PyFloat self; 324 325 public PyObject getSelf() { 326 return self; 327 } 328 329 exposed___mod__(PyFloat self,PyBuiltinFunction.Info info) { 330 super(info); 331 this.self=self; 332 } 333 334 public PyBuiltinFunction makeBound(PyObject self) { 335 return new exposed___mod__((PyFloat)self,info); 336 } 337 338 public PyObject __call__(PyObject arg0) { 339 PyObject ret=self.float___mod__(arg0); 340 if (ret==null) 341 return Py.NotImplemented; 342 return ret; 343 } 344 345 public PyObject inst_call(PyObject gself,PyObject arg0) { 346 PyFloat self=(PyFloat)gself; 347 PyObject ret=self.float___mod__(arg0); 348 if (ret==null) 349 return Py.NotImplemented; 350 return ret; 351 } 352 353 } 354 dict.__setitem__("__mod__",new PyMethodDescr("__mod__",PyFloat.class,1,1,new exposed___mod__(null,null))); 355 class exposed___mul__ extends PyBuiltinFunctionNarrow { 356 357 private PyFloat self; 358 359 public PyObject getSelf() { 360 return self; 361 } 362 363 exposed___mul__(PyFloat self,PyBuiltinFunction.Info info) { 364 super(info); 365 this.self=self; 366 } 367 368 public PyBuiltinFunction makeBound(PyObject self) { 369 return new exposed___mul__((PyFloat)self,info); 370 } 371 372 public PyObject __call__(PyObject arg0) { 373 PyObject ret=self.float___mul__(arg0); 374 if (ret==null) 375 return Py.NotImplemented; 376 return ret; 377 } 378 379 public PyObject inst_call(PyObject gself,PyObject arg0) { 380 PyFloat self=(PyFloat)gself; 381 PyObject ret=self.float___mul__(arg0); 382 if (ret==null) 383 return Py.NotImplemented; 384 return ret; 385 } 386 387 } 388 dict.__setitem__("__mul__",new PyMethodDescr("__mul__",PyFloat.class,1,1,new exposed___mul__(null,null))); 389 class exposed___radd__ extends PyBuiltinFunctionNarrow { 390 391 private PyFloat self; 392 393 public PyObject getSelf() { 394 return self; 395 } 396 397 exposed___radd__(PyFloat self,PyBuiltinFunction.Info info) { 398 super(info); 399 this.self=self; 400 } 401 402 public PyBuiltinFunction makeBound(PyObject self) { 403 return new exposed___radd__((PyFloat)self,info); 404 } 405 406 public PyObject __call__(PyObject arg0) { 407 PyObject ret=self.float___radd__(arg0); 408 if (ret==null) 409 return Py.NotImplemented; 410 return ret; 411 } 412 413 public PyObject inst_call(PyObject gself,PyObject arg0) { 414 PyFloat self=(PyFloat)gself; 415 PyObject ret=self.float___radd__(arg0); 416 if (ret==null) 417 return Py.NotImplemented; 418 return ret; 419 } 420 421 } 422 dict.__setitem__("__radd__",new PyMethodDescr("__radd__",PyFloat.class,1,1,new exposed___radd__(null,null))); 423 class exposed___rdiv__ extends PyBuiltinFunctionNarrow { 424 425 private PyFloat self; 426 427 public PyObject getSelf() { 428 return self; 429 } 430 431 exposed___rdiv__(PyFloat self,PyBuiltinFunction.Info info) { 432 super(info); 433 this.self=self; 434 } 435 436 public PyBuiltinFunction makeBound(PyObject self) { 437 return new exposed___rdiv__((PyFloat)self,info); 438 } 439 440 public PyObject __call__(PyObject arg0) { 441 PyObject ret=self.float___rdiv__(arg0); 442 if (ret==null) 443 return Py.NotImplemented; 444 return ret; 445 } 446 447 public PyObject inst_call(PyObject gself,PyObject arg0) { 448 PyFloat self=(PyFloat)gself; 449 PyObject ret=self.float___rdiv__(arg0); 450 if (ret==null) 451 return Py.NotImplemented; 452 return ret; 453 } 454 455 } 456 dict.__setitem__("__rdiv__",new PyMethodDescr("__rdiv__",PyFloat.class,1,1,new exposed___rdiv__(null,null))); 457 class exposed___rfloordiv__ extends PyBuiltinFunctionNarrow { 458 459 private PyFloat self; 460 461 public PyObject getSelf() { 462 return self; 463 } 464 465 exposed___rfloordiv__(PyFloat self,PyBuiltinFunction.Info info) { 466 super(info); 467 this.self=self; 468 } 469 470 public PyBuiltinFunction makeBound(PyObject self) { 471 return new exposed___rfloordiv__((PyFloat)self,info); 472 } 473 474 public PyObject __call__(PyObject arg0) { 475 PyObject ret=self.float___rfloordiv__(arg0); 476 if (ret==null) 477 return Py.NotImplemented; 478 return ret; 479 } 480 481 public PyObject inst_call(PyObject gself,PyObject arg0) { 482 PyFloat self=(PyFloat)gself; 483 PyObject ret=self.float___rfloordiv__(arg0); 484 if (ret==null) 485 return Py.NotImplemented; 486 return ret; 487 } 488 489 } 490 dict.__setitem__("__rfloordiv__",new PyMethodDescr("__rfloordiv__",PyFloat.class,1,1,new exposed___rfloordiv__(null,null))); 491 class exposed___rmod__ extends PyBuiltinFunctionNarrow { 492 493 private PyFloat self; 494 495 public PyObject getSelf() { 496 return self; 497 } 498 499 exposed___rmod__(PyFloat self,PyBuiltinFunction.Info info) { 500 super(info); 501 this.self=self; 502 } 503 504 public PyBuiltinFunction makeBound(PyObject self) { 505 return new exposed___rmod__((PyFloat)self,info); 506 } 507 508 public PyObject __call__(PyObject arg0) { 509 PyObject ret=self.float___rmod__(arg0); 510 if (ret==null) 511 return Py.NotImplemented; 512 return ret; 513 } 514 515 public PyObject inst_call(PyObject gself,PyObject arg0) { 516 PyFloat self=(PyFloat)gself; 517 PyObject ret=self.float___rmod__(arg0); 518 if (ret==null) 519 return Py.NotImplemented; 520 return ret; 521 } 522 523 } 524 dict.__setitem__("__rmod__",new PyMethodDescr("__rmod__",PyFloat.class,1,1,new exposed___rmod__(null,null))); 525 class exposed___rmul__ extends PyBuiltinFunctionNarrow { 526 527 private PyFloat self; 528 529 public PyObject getSelf() { 530 return self; 531 } 532 533 exposed___rmul__(PyFloat self,PyBuiltinFunction.Info info) { 534 super(info); 535 this.self=self; 536 } 537 538 public PyBuiltinFunction makeBound(PyObject self) { 539 return new exposed___rmul__((PyFloat)self,info); 540 } 541 542 public PyObject __call__(PyObject arg0) { 543 PyObject ret=self.float___rmul__(arg0); 544 if (ret==null) 545 return Py.NotImplemented; 546 return ret; 547 } 548 549 public PyObject inst_call(PyObject gself,PyObject arg0) { 550 PyFloat self=(PyFloat)gself; 551 PyObject ret=self.float___rmul__(arg0); 552 if (ret==null) 553 return Py.NotImplemented; 554 return ret; 555 } 556 557 } 558 dict.__setitem__("__rmul__",new PyMethodDescr("__rmul__",PyFloat.class,1,1,new exposed___rmul__(null,null))); 559 class exposed___rsub__ extends PyBuiltinFunctionNarrow { 560 561 private PyFloat self; 562 563 public PyObject getSelf() { 564 return self; 565 } 566 567 exposed___rsub__(PyFloat self,PyBuiltinFunction.Info info) { 568 super(info); 569 this.self=self; 570 } 571 572 public PyBuiltinFunction makeBound(PyObject self) { 573 return new exposed___rsub__((PyFloat)self,info); 574 } 575 576 public PyObject __call__(PyObject arg0) { 577 PyObject ret=self.float___rsub__(arg0); 578 if (ret==null) 579 return Py.NotImplemented; 580 return ret; 581 } 582 583 public PyObject inst_call(PyObject gself,PyObject arg0) { 584 PyFloat self=(PyFloat)gself; 585 PyObject ret=self.float___rsub__(arg0); 586 if (ret==null) 587 return Py.NotImplemented; 588 return ret; 589 } 590 591 } 592 dict.__setitem__("__rsub__",new PyMethodDescr("__rsub__",PyFloat.class,1,1,new exposed___rsub__(null,null))); 593 class exposed___rtruediv__ extends PyBuiltinFunctionNarrow { 594 595 private PyFloat self; 596 597 public PyObject getSelf() { 598 return self; 599 } 600 601 exposed___rtruediv__(PyFloat self,PyBuiltinFunction.Info info) { 602 super(info); 603 this.self=self; 604 } 605 606 public PyBuiltinFunction makeBound(PyObject self) { 607 return new exposed___rtruediv__((PyFloat)self,info); 608 } 609 610 public PyObject __call__(PyObject arg0) { 611 PyObject ret=self.float___rtruediv__(arg0); 612 if (ret==null) 613 return Py.NotImplemented; 614 return ret; 615 } 616 617 public PyObject inst_call(PyObject gself,PyObject arg0) { 618 PyFloat self=(PyFloat)gself; 619 PyObject ret=self.float___rtruediv__(arg0); 620 if (ret==null) 621 return Py.NotImplemented; 622 return ret; 623 } 624 625 } 626 dict.__setitem__("__rtruediv__",new PyMethodDescr("__rtruediv__",PyFloat.class,1,1,new exposed___rtruediv__(null,null))); 627 class exposed___sub__ extends PyBuiltinFunctionNarrow { 628 629 private PyFloat self; 630 631 public PyObject getSelf() { 632 return self; 633 } 634 635 exposed___sub__(PyFloat self,PyBuiltinFunction.Info info) { 636 super(info); 637 this.self=self; 638 } 639 640 public PyBuiltinFunction makeBound(PyObject self) { 641 return new exposed___sub__((PyFloat)self,info); 642 } 643 644 public PyObject __call__(PyObject arg0) { 645 PyObject ret=self.float___sub__(arg0); 646 if (ret==null) 647 return Py.NotImplemented; 648 return ret; 649 } 650 651 public PyObject inst_call(PyObject gself,PyObject arg0) { 652 PyFloat self=(PyFloat)gself; 653 PyObject ret=self.float___sub__(arg0); 654 if (ret==null) 655 return Py.NotImplemented; 656 return ret; 657 } 658 659 } 660 dict.__setitem__("__sub__",new PyMethodDescr("__sub__",PyFloat.class,1,1,new exposed___sub__(null,null))); 661 class exposed___truediv__ extends PyBuiltinFunctionNarrow { 662 663 private PyFloat self; 664 665 public PyObject getSelf() { 666 return self; 667 } 668 669 exposed___truediv__(PyFloat self,PyBuiltinFunction.Info info) { 670 super(info); 671 this.self=self; 672 } 673 674 public PyBuiltinFunction makeBound(PyObject self) { 675 return new exposed___truediv__((PyFloat)self,info); 676 } 677 678 public PyObject __call__(PyObject arg0) { 679 PyObject ret=self.float___truediv__(arg0); 680 if (ret==null) 681 return Py.NotImplemented; 682 return ret; 683 } 684 685 public PyObject inst_call(PyObject gself,PyObject arg0) { 686 PyFloat self=(PyFloat)gself; 687 PyObject ret=self.float___truediv__(arg0); 688 if (ret==null) 689 return Py.NotImplemented; 690 return ret; 691 } 692 693 } 694 dict.__setitem__("__truediv__",new PyMethodDescr("__truediv__",PyFloat.class,1,1,new exposed___truediv__(null,null))); 695 class exposed___cmp__ extends PyBuiltinFunctionNarrow { 696 697 private PyFloat self; 698 699 public PyObject getSelf() { 700 return self; 701 } 702 703 exposed___cmp__(PyFloat self,PyBuiltinFunction.Info info) { 704 super(info); 705 this.self=self; 706 } 707 708 public PyBuiltinFunction makeBound(PyObject self) { 709 return new exposed___cmp__((PyFloat)self,info); 710 } 711 712 public PyObject __call__(PyObject arg0) { 713 int ret=self.float___cmp__(arg0); 714 if (ret==-2) { 715 throw Py.TypeError("float"+".__cmp__(x,y) requires y to be '"+"float"+"', not a '"+(arg0).getType().fastGetName()+"'"); 716 } 717 return Py.newInteger(ret); 718 } 719 720 public PyObject inst_call(PyObject gself,PyObject arg0) { 721 PyFloat self=(PyFloat)gself; 722 int ret=self.float___cmp__(arg0); 723 if (ret==-2) { 724 throw Py.TypeError("float"+".__cmp__(x,y) requires y to be '"+"float"+"', not a '"+(arg0).getType().fastGetName()+"'"); 725 } 726 return Py.newInteger(ret); 727 } 728 729 } 730 dict.__setitem__("__cmp__",new PyMethodDescr("__cmp__",PyFloat.class,1,1,new exposed___cmp__(null,null))); 731 class exposed___pow__ extends PyBuiltinFunctionNarrow { 732 733 private PyFloat self; 734 735 public PyObject getSelf() { 736 return self; 737 } 738 739 exposed___pow__(PyFloat self,PyBuiltinFunction.Info info) { 740 super(info); 741 this.self=self; 742 } 743 744 public PyBuiltinFunction makeBound(PyObject self) { 745 return new exposed___pow__((PyFloat)self,info); 746 } 747 748 public PyObject __call__(PyObject arg0,PyObject arg1) { 749 PyObject ret=self.float___pow__(arg0,arg1); 750 if (ret==null) 751 return Py.NotImplemented; 752 return ret; 753 } 754 755 public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) { 756 PyFloat self=(PyFloat)gself; 757 PyObject ret=self.float___pow__(arg0,arg1); 758 if (ret==null) 759 return Py.NotImplemented; 760 return ret; 761 } 762 763 public PyObject __call__(PyObject arg0) { 764 PyObject ret=self.float___pow__(arg0,null); 765 if (ret==null) 766 return Py.NotImplemented; 767 return ret; 768 } 769 770 public PyObject inst_call(PyObject gself,PyObject arg0) { 771 PyFloat self=(PyFloat)gself; 772 PyObject ret=self.float___pow__(arg0,null); 773 if (ret==null) 774 return Py.NotImplemented; 775 return ret; 776 } 777 778 } 779 dict.__setitem__("__pow__",new PyMethodDescr("__pow__",PyFloat.class,1,2,new exposed___pow__(null,null))); 780 class exposed___nonzero__ extends PyBuiltinFunctionNarrow { 781 782 private PyFloat self; 783 784 public PyObject getSelf() { 785 return self; 786 } 787 788 exposed___nonzero__(PyFloat self,PyBuiltinFunction.Info info) { 789 super(info); 790 this.self=self; 791 } 792 793 public PyBuiltinFunction makeBound(PyObject self) { 794 return new exposed___nonzero__((PyFloat)self,info); 795 } 796 797 public PyObject __call__() { 798 return Py.newBoolean(self.float___nonzero__()); 799 } 800 801 public PyObject inst_call(PyObject gself) { 802 PyFloat self=(PyFloat)gself; 803 return Py.newBoolean(self.float___nonzero__()); 804 } 805 806 } 807 dict.__setitem__("__nonzero__",new PyMethodDescr("__nonzero__",PyFloat.class,0,0,new exposed___nonzero__(null,null))); 808 class exposed___repr__ extends PyBuiltinFunctionNarrow { 809 810 private PyFloat self; 811 812 public PyObject getSelf() { 813 return self; 814 } 815 816 exposed___repr__(PyFloat self,PyBuiltinFunction.Info info) { 817 super(info); 818 this.self=self; 819 } 820 821 public PyBuiltinFunction makeBound(PyObject self) { 822 return new exposed___repr__((PyFloat)self,info); 823 } 824 825 public PyObject __call__() { 826 return new PyString(self.float_toString()); 827 } 828 829 public PyObject inst_call(PyObject gself) { 830 PyFloat self=(PyFloat)gself; 831 return new PyString(self.float_toString()); 832 } 833 834 } 835 dict.__setitem__("__repr__",new PyMethodDescr("__repr__",PyFloat.class,0,0,new exposed___repr__(null,null))); 836 class exposed___str__ extends PyBuiltinFunctionNarrow { 837 838 private PyFloat self; 839 840 public PyObject getSelf() { 841 return self; 842 } 843 844 exposed___str__(PyFloat self,PyBuiltinFunction.Info info) { 845 super(info); 846 this.self=self; 847 } 848 849 public PyBuiltinFunction makeBound(PyObject self) { 850 return new exposed___str__((PyFloat)self,info); 851 } 852 853 public PyObject __call__() { 854 return new PyString(self.float_toString()); 855 } 856 857 public PyObject inst_call(PyObject gself) { 858 PyFloat self=(PyFloat)gself; 859 return new PyString(self.float_toString()); 860 } 861 862 } 863 dict.__setitem__("__str__",new PyMethodDescr("__str__",PyFloat.class,0,0,new exposed___str__(null,null))); 864 class exposed___hash__ extends PyBuiltinFunctionNarrow { 865 866 private PyFloat self; 867 868 public PyObject getSelf() { 869 return self; 870 } 871 872 exposed___hash__(PyFloat self,PyBuiltinFunction.Info info) { 873 super(info); 874 this.self=self; 875 } 876 877 public PyBuiltinFunction makeBound(PyObject self) { 878 return new exposed___hash__((PyFloat)self,info); 879 } 880 881 public PyObject __call__() { 882 return Py.newFloat(self.float_hashCode()); 883 } 884 885 public PyObject inst_call(PyObject gself) { 886 PyFloat self=(PyFloat)gself; 887 return Py.newFloat(self.float_hashCode()); 888 } 889 890 } 891 dict.__setitem__("__hash__",new PyMethodDescr("__hash__",PyFloat.class,0,0,new exposed___hash__(null,null))); 892 dict.__setitem__("__new__",new PyNewWrapper(PyFloat.class,"__new__",-1,-1) { 893 public PyObject new_impl(boolean init,PyType subtype,PyObject[]args,String []keywords) { 894 return float_new(this,init,subtype,args,keywords); 895 } 896 }); 897 } 898 899 public static PyObject float_new(PyObject new_, boolean init, PyType subtype, 900 PyObject[] args, String [] keywords) { 901 ArgParser ap = new ArgParser("float", args, keywords, new String [] { "x" }, 0); 902 PyObject x = ap.getPyObject(0, null); 903 if (x == null) 904 return new PyFloat(0.0); 905 return x.__float__(); 906 } 908 private static final PyType FLOATTYPE = PyType.fromClass(PyFloat.class); 909 910 private double value; 911 912 public PyFloat(double v) { 913 super(FLOATTYPE); 914 value = v; 915 } 916 917 public PyFloat(float v) { 918 this((double)v); 919 } 920 921 public String safeRepr() throws PyIgnoreMethodTag { 922 return "'float' object"; 923 } 924 925 public double getValue() { 926 return value; 927 } 928 929 public String toString() { 930 return float_toString(); 931 } 932 933 final String float_toString() { 934 String s = Double.toString(value); 935 if (s.indexOf('E') == -1) { 938 while (true) { 939 int n = s.length(); 940 if (n <= 2) 941 break; 942 if (s.charAt(n-1) == '0' && s.charAt(n-2) != '.') { 943 s = s.substring(0,n-1); 944 continue; 945 } 946 break; 947 } 948 } 949 return s; 950 } 951 952 public int hashCode() { 953 return float_hashCode(); 954 } 955 956 final int float_hashCode() { 957 double intPart = Math.floor(value); 958 double fractPart = value-intPart; 959 960 if (fractPart == 0) { 961 if (intPart <= Integer.MAX_VALUE && intPart >= Integer.MIN_VALUE) 962 return (int)value; 963 else 964 return __long__().hashCode(); 965 } else { 966 long v = Double.doubleToLongBits(value); 967 return (int)v ^ (int)(v >> 32); 968 } 969 } 970 971 public boolean __nonzero__() { 972 return float___nonzero__(); 973 } 974 975 final boolean float___nonzero__() { 976 return value != 0; 977 } 978 979 public Object __tojava__(Class c) { 980 if (c == Double.TYPE || c == Number .class || 981 c == Double .class || c == Object .class || c == Serializable .class) 982 { 983 return new Double (value); 984 } 985 if (c == Float.TYPE || c == Float .class) { 986 return new Float (value); 987 } 988 return super.__tojava__(c); 989 } 990 991 public int __cmp__(PyObject other) { 992 return float___cmp__(other); 993 } 994 995 final int float___cmp__(PyObject other) { 996 if (!canCoerce(other)) 997 return -2; 998 double v = coerce(other); 999 return value < v ? -1 : value > v ? 1 : 0; 1000 } 1001 1002 public Object __coerce_ex__(PyObject other) { 1003 if (other instanceof PyFloat) 1004 return other; 1005 else { 1006 if (other instanceof PyInteger) 1007 return new PyFloat((double)((PyInteger)other).getValue()); 1008 if (other instanceof PyLong) 1009 return new PyFloat(((PyLong)other).doubleValue()); 1010 else 1011 return Py.None; 1012 } 1013 } 1014 1015 private static final boolean canCoerce(PyObject other) { 1016 return other instanceof PyFloat || other instanceof PyInteger || 1017 other instanceof PyLong; 1018 } 1019 1020 private static final double coerce(PyObject other) { 1021 if (other instanceof PyFloat) 1022 return ((PyFloat) other).value; 1023 else if (other instanceof PyInteger) 1024 return ((PyInteger) other).getValue(); 1025 else if (other instanceof PyLong) 1026 return ((PyLong) other).doubleValue(); 1027 else 1028 throw Py.TypeError("xxx"); 1029 } 1030 1031 1032 public PyObject __add__(PyObject right) { 1033 return float___add__(right); 1034 } 1035 1036 final PyObject float___add__(PyObject right) { 1037 if (!canCoerce(right)) 1038 return null; 1039 double rightv = coerce(right); 1040 return new PyFloat(value + rightv); 1041 } 1042 1043 public PyObject __radd__(PyObject left) { 1044 return float___radd__(left); 1045 } 1046 1047 final PyObject float___radd__(PyObject left) { 1048 return __add__(left); 1049 } 1050 1051 public PyObject __sub__(PyObject right) { 1052 return float___sub__(right); 1053 } 1054 1055 final PyObject float___sub__(PyObject right) { 1056 if (!canCoerce(right)) 1057 return null; 1058 double rightv = coerce(right); 1059 return new PyFloat(value - rightv); 1060 } 1061 1062 public PyObject __rsub__(PyObject left) { 1063 return float___rsub__(left); 1064 } 1065 1066 final PyObject float___rsub__(PyObject left) { 1067 if (!canCoerce(left)) 1068 return null; 1069 double leftv = coerce(left); 1070 return new PyFloat(leftv - value); 1071 } 1072 1073 public PyObject __mul__(PyObject right) { 1074 return float___mul__(right); 1075 } 1076 1077 final PyObject float___mul__(PyObject right) { 1078 if (!canCoerce(right)) 1079 return null; 1080 double rightv = coerce(right); 1081 return new PyFloat(value * rightv); 1082 } 1083 1084 public PyObject __rmul__(PyObject left) { 1085 return float___rmul__(left); 1086 } 1087 1088 final PyObject float___rmul__(PyObject left) { 1089 return __mul__(left); 1090 } 1091 1092 public PyObject __div__(PyObject right) { 1093 return float___div__(right); 1094 } 1095 1096 final PyObject float___div__(PyObject right) { 1097 if (!canCoerce(right)) 1098 return null; 1099 if (Options.divisionWarning >= 2) 1100 Py.warning(Py.DeprecationWarning, "classic float division"); 1101 double rightv = coerce(right); 1102 if (rightv == 0) 1103 throw Py.ZeroDivisionError("float division"); 1104 return new PyFloat(value / rightv); 1105 } 1106 1107 public PyObject __rdiv__(PyObject left) { 1108 return float___rdiv__(left); 1109 } 1110 1111 final PyObject float___rdiv__(PyObject left) { 1112 if (!canCoerce(left)) 1113 return null; 1114 if (Options.divisionWarning >= 2) 1115 Py.warning(Py.DeprecationWarning, "classic float division"); 1116 double leftv = coerce(left); 1117 if (value == 0) 1118 throw Py.ZeroDivisionError("float division"); 1119 return new PyFloat(leftv / value); 1120 } 1121 1122 public PyObject __floordiv__(PyObject right) { 1123 return float___floordiv__(right); 1124 } 1125 1126 final PyObject float___floordiv__(PyObject right) { 1127 if (!canCoerce(right)) 1128 return null; 1129 double rightv = coerce(right); 1130 if (rightv == 0) 1131 throw Py.ZeroDivisionError("float division"); 1132 return new PyFloat(Math.floor(value / rightv)); 1133 } 1134 1135 public PyObject __rfloordiv__(PyObject left) { 1136 return float___rfloordiv__(left); 1137 } 1138 1139 final PyObject float___rfloordiv__(PyObject left) { 1140 if (!canCoerce(left)) 1141 return null; 1142 double leftv = coerce(left); 1143 if (value == 0) 1144 throw Py.ZeroDivisionError("float division"); 1145 return new PyFloat(Math.floor(leftv / value)); 1146 } 1147 1148 public PyObject __truediv__(PyObject right) { 1149 return float___truediv__(right); 1150 } 1151 1152 final PyObject float___truediv__(PyObject right) { 1153 if (!canCoerce(right)) 1154 return null; 1155 double rightv = coerce(right); 1156 if (rightv == 0) 1157 throw Py.ZeroDivisionError("float division"); 1158 return new PyFloat(value / rightv); 1159 } 1160 1161 public PyObject __rtruediv__(PyObject left) { 1162 return float___rtruediv__(left); 1163 } 1164 1165 final PyObject float___rtruediv__(PyObject left) { 1166 if (!canCoerce(left)) 1167 return null; 1168 double leftv = coerce(left); 1169 if (value == 0) 1170 throw Py.ZeroDivisionError("float division"); 1171 return new PyFloat(leftv / value); 1172 } 1173 1174 private static double modulo(double x, double y) { 1175 if (y == 0) 1176 throw Py.ZeroDivisionError("float modulo"); 1177 double z = Math.IEEEremainder(x, y); 1178 if (z*y < 0) 1179 z += y; 1180 return z; 1181 } 1182 1183 public PyObject __mod__(PyObject right) { 1184 return float___mod__(right); 1185 } 1186 1187 final PyObject float___mod__(PyObject right) { 1188 if (!canCoerce(right)) 1189 return null; 1190 double rightv = coerce(right); 1191 return new PyFloat(modulo(value, rightv)); 1192 } 1193 1194 public PyObject __rmod__(PyObject left) { 1195 return float___rmod__(left); 1196 } 1197 1198 final PyObject float___rmod__(PyObject left) { 1199 if (!canCoerce(left)) 1200 return null; 1201 double leftv = coerce(left); 1202 return new PyFloat(modulo(leftv, value)); 1203 } 1204 1205 public PyObject __divmod__(PyObject right) { 1206 return float___divmod__(right); 1207 } 1208 1209 final PyObject float___divmod__(PyObject right) { 1210 if (!canCoerce(right)) 1211 return null; 1212 double rightv = coerce(right); 1213 1214 if (rightv == 0) 1215 throw Py.ZeroDivisionError("float division"); 1216 double z = Math.floor(value / rightv); 1217 1218 return new PyTuple( 1219 new PyObject[] {new PyFloat(z), new PyFloat(value-z*rightv)} 1220 ); 1221 } 1222 1223 public PyObject __rdivmod__(PyObject left) { 1224 if (!canCoerce(left)) 1225 return null; 1226 double leftv = coerce(left); 1227 1228 if (value == 0) 1229 throw Py.ZeroDivisionError("float division"); 1230 double z = Math.floor(leftv / value); 1231 1232 return new PyTuple( 1233 new PyObject[] {new PyFloat(z), new PyFloat(leftv-z*value)} 1234 ); 1235 } 1236 1237 1238 public PyObject __pow__(PyObject right, PyObject modulo) { 1239 return float___pow__(right, modulo); 1240 } 1241 1242 final PyObject float___pow__(PyObject right, PyObject modulo) { 1243 if (!canCoerce(right)) 1244 return null; 1245 1246 if (modulo != null) { 1247 throw Py.TypeError("pow() 3rd argument not allowed " + 1248 "unless all arguments are integers"); 1249 } 1250 1251 return _pow(value, coerce(right), modulo); 1252 } 1253 1254 public PyObject __rpow__(PyObject left) { 1255 if (!canCoerce(left)) 1256 return null; 1257 1258 return _pow(coerce(left), value, null); 1259 } 1260 1261 private static PyFloat _pow(double value, double iw, PyObject modulo) { 1262 if (iw == 0) { 1264 if (modulo != null) 1265 return new PyFloat(modulo(1.0, coerce(modulo))); 1266 return new PyFloat(1.0); 1267 } 1268 if (value == 0.0) { 1269 if (iw < 0.0) 1270 throw Py.ZeroDivisionError("0.0 cannot be raised to a " + 1271 "negative power"); 1272 return new PyFloat(0); 1273 } 1274 1275 double ret = Math.pow(value, iw); 1276 if (modulo == null) { 1277 return new PyFloat(ret); 1278 } else { 1279 return new PyFloat(modulo(ret, coerce(modulo))); 1280 } 1281 } 1282 1283 public PyObject __neg__() { 1284 return float___neg__(); 1285 } 1286 1287 final PyObject float___neg__() { 1288 return new PyFloat(-value); 1289 } 1290 1291 public PyObject __pos__() { 1292 return float___pos__(); 1293 } 1294 1295 final PyObject float___pos__() { 1296 return this; 1297 } 1298 1299 public PyObject __invert__() { 1300 throw Py.TypeError("bad operand type for unary ~"); 1301 } 1302 1303 public PyObject __abs__() { 1304 return float___abs__(); 1305 } 1306 1307 final PyObject float___abs__() { 1308 if (value >= 0) 1309 return this; 1310 else 1311 return __neg__(); 1312 } 1313 1314 public PyObject __int__() { 1315 return float___int__(); 1316 } 1317 1318 final PyInteger float___int__() { 1319 if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) { 1320 return new PyInteger((int)value); 1321 } 1322 throw Py.OverflowError("float too large to convert"); 1323 } 1324 1325 public PyLong __long__() { 1326 return float___long__(); 1327 } 1328 1329 final PyLong float___long__() { 1330 return new PyLong(value); 1331 } 1332 1333 public PyFloat __float__() { 1334 return float___float__(); 1335 } 1336 1337 final PyFloat float___float__() { 1338 return this; 1339 } 1340 public PyComplex __complex__() { 1341 return new PyComplex(value, 0.); 1342 } 1343 1344 public boolean isMappingType() throws PyIgnoreMethodTag { return false; } 1345 public boolean isSequenceType() throws PyIgnoreMethodTag { return false; } 1346 1347} 1348 | Popular Tags |