Mercurial > hg > xemacs-beta
comparison src/number.c @ 5581:56144c8593a8
Mechanically change INT to FIXNUM in our sources.
src/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT (where it refers to non-bignum Lisp
integers) to FIXNUM in our sources. Done for the following
functions, enums, and macros: Lisp_Type_Int_Even,
Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(),
XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(),
EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to
MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to
NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT.
The EMACS_INT typedef was not changed, it does not describe
non-bignum Lisp integers.
Script that did the change available in
http://mid.gmane.org/20067.17650.181273.12014@parhasard.net .
modules/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
[...]
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers. See the src/ChangeLog entry for more details.
man/ChangeLog addition:
2011-10-09 Aidan Kehoe <kehoea@parhasard.net>
* internals/internals.texi (How Lisp Objects Are Represented in C):
* internals/internals.texi (Integers and Characters):
Mechanically change INT to FIXNUM, where the usage describes non-bignum
Lisp integers.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 09 Oct 2011 09:51:57 +0100 |
parents | 2aa9cd456ae7 |
children | c9e5612f5424 |
comparison
equal
deleted
inserted
replaced
5580:a0e81357194e | 5581:56144c8593a8 |
---|---|
248 { | 248 { |
249 return Fcanonicalize_number (make_bignum_bg | 249 return Fcanonicalize_number (make_bignum_bg |
250 (XRATIO_DENOMINATOR (rational))); | 250 (XRATIO_DENOMINATOR (rational))); |
251 } | 251 } |
252 #endif | 252 #endif |
253 return make_int (1); | 253 return make_fixnum (1); |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 /******************************** Bigfloats *********************************/ | 257 /******************************** Bigfloats *********************************/ |
258 #ifdef HAVE_BIGFLOAT | 258 #ifdef HAVE_BIGFLOAT |
330 CHECK_BIGFLOAT (f); | 330 CHECK_BIGFLOAT (f); |
331 #ifdef HAVE_BIGNUM | 331 #ifdef HAVE_BIGNUM |
332 bignum_set_ulong (scratch_bignum, XBIGFLOAT_GET_PREC (f)); | 332 bignum_set_ulong (scratch_bignum, XBIGFLOAT_GET_PREC (f)); |
333 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); | 333 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); |
334 #else | 334 #else |
335 return make_int ((int) XBIGFLOAT_GET_PREC (f)); | 335 return make_fixnum ((int) XBIGFLOAT_GET_PREC (f)); |
336 #endif | 336 #endif |
337 } | 337 } |
338 | 338 |
339 DEFUN ("bigfloat-set-precision", Fbigfloat_set_precision, 2, 2, 0, /* | 339 DEFUN ("bigfloat-set-precision", Fbigfloat_set_precision, 2, 2, 0, /* |
340 Set the precision of F, a bigfloat, to PRECISION, a nonnegative integer. | 340 Set the precision of F, a bigfloat, to PRECISION, a nonnegative integer. |
345 (f, precision)) | 345 (f, precision)) |
346 { | 346 { |
347 unsigned long prec; | 347 unsigned long prec; |
348 | 348 |
349 CHECK_BIGFLOAT (f); | 349 CHECK_BIGFLOAT (f); |
350 if (INTP (precision)) | 350 if (FIXNUMP (precision)) |
351 { | 351 { |
352 prec = (XINT (precision) <= 0) ? 1UL : (unsigned long) XINT (precision); | 352 prec = (XFIXNUM (precision) <= 0) ? 1UL : (unsigned long) XFIXNUM (precision); |
353 } | 353 } |
354 #ifdef HAVE_BIGNUM | 354 #ifdef HAVE_BIGNUM |
355 else if (BIGNUMP (precision)) | 355 else if (BIGNUMP (precision)) |
356 { | 356 { |
357 prec = bignum_fits_ulong_p (XBIGNUM_DATA (precision)) | 357 prec = bignum_fits_ulong_p (XBIGNUM_DATA (precision)) |
376 { | 376 { |
377 unsigned long prec; | 377 unsigned long prec; |
378 | 378 |
379 CONCHECK_INTEGER (*val); | 379 CONCHECK_INTEGER (*val); |
380 #ifdef HAVE_BIGFLOAT | 380 #ifdef HAVE_BIGFLOAT |
381 if (INTP (*val)) | 381 if (FIXNUMP (*val)) |
382 prec = XINT (*val); | 382 prec = XFIXNUM (*val); |
383 else | 383 else |
384 { | 384 { |
385 if (!bignum_fits_ulong_p (XBIGNUM_DATA (*val))) | 385 if (!bignum_fits_ulong_p (XBIGNUM_DATA (*val))) |
386 args_out_of_range_3 (*val, Qzero, Vbigfloat_max_prec); | 386 args_out_of_range_3 (*val, Qzero, Vbigfloat_max_prec); |
387 prec = bignum_to_ulong (XBIGNUM_DATA (*val)); | 387 prec = bignum_to_ulong (XBIGNUM_DATA (*val)); |
444 #endif | 444 #endif |
445 #ifdef HAVE_BIGNUM | 445 #ifdef HAVE_BIGNUM |
446 if (BIGNUMP (number) && bignum_fits_emacs_int_p (XBIGNUM_DATA (number))) | 446 if (BIGNUMP (number) && bignum_fits_emacs_int_p (XBIGNUM_DATA (number))) |
447 { | 447 { |
448 EMACS_INT n = bignum_to_emacs_int (XBIGNUM_DATA (number)); | 448 EMACS_INT n = bignum_to_emacs_int (XBIGNUM_DATA (number)); |
449 if (NUMBER_FITS_IN_AN_EMACS_INT (n)) | 449 if (NUMBER_FITS_IN_A_FIXNUM (n)) |
450 number = make_int (n); | 450 number = make_fixnum (n); |
451 } | 451 } |
452 #endif | 452 #endif |
453 return number; | 453 return number; |
454 } | 454 } |
455 | 455 |
456 enum number_type | 456 enum number_type |
457 get_number_type (Lisp_Object arg) | 457 get_number_type (Lisp_Object arg) |
458 { | 458 { |
459 if (INTP (arg)) | 459 if (FIXNUMP (arg)) |
460 return FIXNUM_T; | 460 return FIXNUM_T; |
461 #ifdef HAVE_BIGNUM | 461 #ifdef HAVE_BIGNUM |
462 if (BIGNUMP (arg)) | 462 if (BIGNUMP (arg)) |
463 return BIGNUM_T; | 463 return BIGNUM_T; |
464 #endif | 464 #endif |
490 ) | 490 ) |
491 { | 491 { |
492 enum number_type current_type; | 492 enum number_type current_type; |
493 | 493 |
494 if (CHARP (number)) | 494 if (CHARP (number)) |
495 number = make_int (XCHAR (number)); | 495 number = make_fixnum (XCHAR (number)); |
496 else if (MARKERP (number)) | 496 else if (MARKERP (number)) |
497 number = make_int (marker_position (number)); | 497 number = make_fixnum (marker_position (number)); |
498 | 498 |
499 /* Note that CHECK_NUMBER ensures that NUMBER is a supported type. Hence, | 499 /* Note that CHECK_NUMBER ensures that NUMBER is a supported type. Hence, |
500 we ABORT() in the #else sections below, because it shouldn't be possible | 500 we ABORT() in the #else sections below, because it shouldn't be possible |
501 to arrive there. */ | 501 to arrive there. */ |
502 CHECK_NUMBER (number); | 502 CHECK_NUMBER (number); |
508 { | 508 { |
509 case FIXNUM_T: | 509 case FIXNUM_T: |
510 return number; | 510 return number; |
511 case BIGNUM_T: | 511 case BIGNUM_T: |
512 #ifdef HAVE_BIGNUM | 512 #ifdef HAVE_BIGNUM |
513 return make_bignum (XREALINT (number)); | 513 return make_bignum (XREALFIXNUM (number)); |
514 #else | 514 #else |
515 ABORT (); | 515 ABORT (); |
516 #endif /* HAVE_BIGNUM */ | 516 #endif /* HAVE_BIGNUM */ |
517 case RATIO_T: | 517 case RATIO_T: |
518 #ifdef HAVE_RATIO | 518 #ifdef HAVE_RATIO |
519 return make_ratio (XREALINT (number), 1UL); | 519 return make_ratio (XREALFIXNUM (number), 1UL); |
520 #else | 520 #else |
521 ABORT (); | 521 ABORT (); |
522 #endif /* HAVE_RATIO */ | 522 #endif /* HAVE_RATIO */ |
523 case FLOAT_T: | 523 case FLOAT_T: |
524 return make_float (XREALINT (number)); | 524 return make_float (XREALFIXNUM (number)); |
525 case BIGFLOAT_T: | 525 case BIGFLOAT_T: |
526 #ifdef HAVE_BIGFLOAT | 526 #ifdef HAVE_BIGFLOAT |
527 return make_bigfloat (XREALINT (number), precision); | 527 return make_bigfloat (XREALFIXNUM (number), precision); |
528 #else | 528 #else |
529 ABORT (); | 529 ABORT (); |
530 #endif /* HAVE_BIGFLOAT */ | 530 #endif /* HAVE_BIGFLOAT */ |
531 } | 531 } |
532 case BIGNUM_T: | 532 case BIGNUM_T: |
533 #ifdef HAVE_BIGNUM | 533 #ifdef HAVE_BIGNUM |
534 switch (type) | 534 switch (type) |
535 { | 535 { |
536 case FIXNUM_T: | 536 case FIXNUM_T: |
537 return make_int (bignum_to_long (XBIGNUM_DATA (number))); | 537 return make_fixnum (bignum_to_long (XBIGNUM_DATA (number))); |
538 case BIGNUM_T: | 538 case BIGNUM_T: |
539 return number; | 539 return number; |
540 case RATIO_T: | 540 case RATIO_T: |
541 #ifdef HAVE_RATIO | 541 #ifdef HAVE_RATIO |
542 bignum_set_long (scratch_bignum, 1L); | 542 bignum_set_long (scratch_bignum, 1L); |
566 switch (type) | 566 switch (type) |
567 { | 567 { |
568 case FIXNUM_T: | 568 case FIXNUM_T: |
569 bignum_div (scratch_bignum, XRATIO_NUMERATOR (number), | 569 bignum_div (scratch_bignum, XRATIO_NUMERATOR (number), |
570 XRATIO_DENOMINATOR (number)); | 570 XRATIO_DENOMINATOR (number)); |
571 return make_int (bignum_to_long (scratch_bignum)); | 571 return make_fixnum (bignum_to_long (scratch_bignum)); |
572 case BIGNUM_T: | 572 case BIGNUM_T: |
573 bignum_div (scratch_bignum, XRATIO_NUMERATOR (number), | 573 bignum_div (scratch_bignum, XRATIO_NUMERATOR (number), |
574 XRATIO_DENOMINATOR (number)); | 574 XRATIO_DENOMINATOR (number)); |
575 return make_bignum_bg (scratch_bignum); | 575 return make_bignum_bg (scratch_bignum); |
576 case RATIO_T: | 576 case RATIO_T: |
625 case BIGFLOAT_T: | 625 case BIGFLOAT_T: |
626 #ifdef HAVE_BIGFLOAT | 626 #ifdef HAVE_BIGFLOAT |
627 switch (type) | 627 switch (type) |
628 { | 628 { |
629 case FIXNUM_T: | 629 case FIXNUM_T: |
630 return make_int (bigfloat_to_long (XBIGFLOAT_DATA (number))); | 630 return make_fixnum (bigfloat_to_long (XBIGFLOAT_DATA (number))); |
631 case BIGNUM_T: | 631 case BIGNUM_T: |
632 #ifdef HAVE_BIGNUM | 632 #ifdef HAVE_BIGNUM |
633 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (number)); | 633 bignum_set_bigfloat (scratch_bignum, XBIGFLOAT_DATA (number)); |
634 return make_bignum_bg (scratch_bignum); | 634 return make_bignum_bg (scratch_bignum); |
635 #else | 635 #else |
664 promote_args (Lisp_Object *arg1, Lisp_Object *arg2) | 664 promote_args (Lisp_Object *arg1, Lisp_Object *arg2) |
665 { | 665 { |
666 enum number_type type1, type2; | 666 enum number_type type1, type2; |
667 | 667 |
668 if (CHARP (*arg1)) | 668 if (CHARP (*arg1)) |
669 *arg1 = make_int (XCHAR (*arg1)); | 669 *arg1 = make_fixnum (XCHAR (*arg1)); |
670 else if (MARKERP (*arg1)) | 670 else if (MARKERP (*arg1)) |
671 *arg1 = make_int (marker_position (*arg1)); | 671 *arg1 = make_fixnum (marker_position (*arg1)); |
672 if (CHARP (*arg2)) | 672 if (CHARP (*arg2)) |
673 *arg2 = make_int (XCHAR (*arg2)); | 673 *arg2 = make_fixnum (XCHAR (*arg2)); |
674 else if (MARKERP (*arg2)) | 674 else if (MARKERP (*arg2)) |
675 *arg2 = make_int (marker_position (*arg2)); | 675 *arg2 = make_fixnum (marker_position (*arg2)); |
676 | 676 |
677 CHECK_NUMBER (*arg1); | 677 CHECK_NUMBER (*arg1); |
678 CHECK_NUMBER (*arg2); | 678 CHECK_NUMBER (*arg2); |
679 | 679 |
680 type1 = get_number_type (*arg1); | 680 type1 = get_number_type (*arg1); |
750 prec = bigfloat_get_default_prec (); | 750 prec = bigfloat_get_default_prec (); |
751 else | 751 else |
752 { | 752 { |
753 CHECK_INTEGER (precision); | 753 CHECK_INTEGER (precision); |
754 #ifdef HAVE_BIGNUM | 754 #ifdef HAVE_BIGNUM |
755 if (INTP (precision)) | 755 if (FIXNUMP (precision)) |
756 #endif /* HAVE_BIGNUM */ | 756 #endif /* HAVE_BIGNUM */ |
757 prec = (unsigned long) XREALINT (precision); | 757 prec = (unsigned long) XREALFIXNUM (precision); |
758 #ifdef HAVE_BIGNUM | 758 #ifdef HAVE_BIGNUM |
759 else | 759 else |
760 { | 760 { |
761 if (!bignum_fits_ulong_p (XBIGNUM_DATA (precision))) | 761 if (!bignum_fits_ulong_p (XBIGNUM_DATA (precision))) |
762 args_out_of_range (precision, Vbigfloat_max_prec); | 762 args_out_of_range (precision, Vbigfloat_max_prec); |
822 The default floating-point precision for newly created floating point values. | 822 The default floating-point precision for newly created floating point values. |
823 This should be 0 to create Lisp float types, or an unsigned integer no greater | 823 This should be 0 to create Lisp float types, or an unsigned integer no greater |
824 than `bigfloat-maximum-precision' to create Lisp bigfloat types with the | 824 than `bigfloat-maximum-precision' to create Lisp bigfloat types with the |
825 indicated precision. | 825 indicated precision. |
826 */ default_float_precision_changed); | 826 */ default_float_precision_changed); |
827 Vdefault_float_precision = make_int (0); | 827 Vdefault_float_precision = make_fixnum (0); |
828 | 828 |
829 DEFVAR_CONST_LISP ("bigfloat-maximum-precision", &Vbigfloat_max_prec /* | 829 DEFVAR_CONST_LISP ("bigfloat-maximum-precision", &Vbigfloat_max_prec /* |
830 The maximum number of bits of precision a bigfloat can have. | 830 The maximum number of bits of precision a bigfloat can have. |
831 This is determined by the underlying library used to implement bigfloats. | 831 This is determined by the underlying library used to implement bigfloats. |
832 */); | 832 */); |
833 | 833 |
834 #ifdef HAVE_BIGFLOAT | 834 #ifdef HAVE_BIGFLOAT |
835 /* Don't create a bignum here. Otherwise, we lose with NEW_GC + pdump. | 835 /* Don't create a bignum here. Otherwise, we lose with NEW_GC + pdump. |
836 See reinit_vars_of_number(). */ | 836 See reinit_vars_of_number(). */ |
837 Vbigfloat_max_prec = make_int (EMACS_INT_MAX); | 837 Vbigfloat_max_prec = make_fixnum (MOST_POSITIVE_FIXNUM); |
838 #else | 838 #else |
839 Vbigfloat_max_prec = make_int (0); | 839 Vbigfloat_max_prec = make_fixnum (0); |
840 #endif /* HAVE_BIGFLOAT */ | 840 #endif /* HAVE_BIGFLOAT */ |
841 | 841 |
842 Fprovide (intern ("number-types")); | 842 Fprovide (intern ("number-types")); |
843 #ifdef HAVE_BIGNUM | 843 #ifdef HAVE_BIGNUM |
844 Fprovide (intern ("bignum")); | 844 Fprovide (intern ("bignum")); |