1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 14:30:34 +02:00

Make SCM_NUMP and SCM_NUMBERP more extensible

* libguile/numbers.h (SCM_NUMP, SCM_NUMBERP): Mask out more bits in the
  cell type field when doing the comparison, in order to accept future
  numeric types that have not yet been implemented.  This should allow
  us to add more core numeric types without breaking ABI compatibility.
  As a bonus, these macros are now more efficient.
This commit is contained in:
Mark H Weaver 2011-02-10 19:04:05 -05:00 committed by Andy Wingo
parent f135fc3eda
commit 5093e51839

View file

@ -138,9 +138,7 @@ typedef scm_t_int32 scm_t_wchar;
#define SCM_NUMBERP(x) (SCM_I_INUMP(x) || SCM_NUMP(x))
#define SCM_NUMP(x) (!SCM_IMP(x) \
&& (((0xfcff & SCM_CELL_TYPE (x)) == scm_tc7_number) \
|| ((0xfbff & SCM_CELL_TYPE (x)) == scm_tc7_number)))
/* 0xfcff (#b1100) for 0 free, 1 big, 2 real, 3 complex, then 0xfbff (#b1011) for 4 fraction */
&& ((0x00ff & SCM_CELL_TYPE (x)) == scm_tc7_number))
#define SCM_FRACTIONP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_fraction)
#define SCM_FRACTION_NUMERATOR(x) (SCM_CELL_OBJECT_1 (x))