1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

clean up smob macro implementation

* libguile/smob.h: Regularize the SCM_SMOB macros, and make them all go
  through some generic SMOB accessor macros.

* libguile/smob.c (scm_i_set_smob_flags): Remove, as it is unused.
This commit is contained in:
Andy Wingo 2009-12-08 22:14:26 +01:00
parent 66e78727d6
commit 56164dc47f
2 changed files with 37 additions and 26 deletions

View file

@ -54,14 +54,6 @@
long scm_numsmob;
scm_smob_descriptor scm_smobs[MAX_SMOB_COUNT];
/* Lower 16 bit of data must be zero.
*/
void
scm_i_set_smob_flags (SCM x, scm_t_bits data)
{
SCM_SET_CELL_WORD_0 (x, (SCM_CELL_WORD_0 (x) & 0xFFFF) | data);
}
void
scm_assert_smob_type (scm_t_bits tag, SCM val)
{

View file

@ -122,24 +122,44 @@ while (0)
} while (0)
#define SCM_SMOB_FLAGS(x) (SCM_CELL_WORD_0 (x) >> 16)
#define SCM_SMOB_DATA(x) (SCM_CELL_WORD_1 (x))
#define SCM_SMOB_DATA_2(x) (SCM_CELL_WORD_2 (x))
#define SCM_SMOB_DATA_3(x) (SCM_CELL_WORD_3 (x))
#define SCM_SET_SMOB_DATA(x, data) (SCM_SET_CELL_WORD_1 ((x), (data)))
#define SCM_SET_SMOB_DATA_2(x, data) (SCM_SET_CELL_WORD_2 ((x), (data)))
#define SCM_SET_SMOB_DATA_3(x, data) (SCM_SET_CELL_WORD_3 ((x), (data)))
#define SCM_SET_SMOB_FLAGS(x, data) (scm_i_set_smob_flags((x),(data)<<16))
#define SCM_SMOB_DATA_N(x, n) (SCM_CELL_WORD ((x), (n)))
#define SCM_SET_SMOB_DATA_N(x, n, data) (SCM_SET_CELL_WORD ((x), (n), (data)))
#define SCM_SMOB_DATA_0(x) (SCM_SMOB_DATA_N ((x), 0))
#define SCM_SMOB_DATA_1(x) (SCM_SMOB_DATA_N ((x), 1))
#define SCM_SMOB_DATA_2(x) (SCM_SMOB_DATA_N ((x), 2))
#define SCM_SMOB_DATA_3(x) (SCM_SMOB_DATA_N ((x), 3))
#define SCM_SET_SMOB_DATA_0(x, data) (SCM_SET_SMOB_DATA_N ((x), 0, (data)))
#define SCM_SET_SMOB_DATA_1(x, data) (SCM_SET_SMOB_DATA_N ((x), 1, (data)))
#define SCM_SET_SMOB_DATA_2(x, data) (SCM_SET_SMOB_DATA_N ((x), 2, (data)))
#define SCM_SET_SMOB_DATA_3(x, data) (SCM_SET_SMOB_DATA_N ((x), 3, (data)))
#define SCM_SMOB_FLAGS(x) (SCM_SMOB_DATA_0 (x) >> 16)
#define SCM_SMOB_DATA(x) (SCM_SMOB_DATA_1 (x))
#define SCM_SET_SMOB_FLAGS(x, data) (SCM_SET_SMOB_DATA_0 ((x), (SCM_CELL_TYPE (x)&0xffff)|((data)<<16)))
#define SCM_SET_SMOB_DATA(x, data) (SCM_SET_SMOB_DATA_1 ((x), (data)))
#define SCM_SMOB_OBJECT_N(x,n) (SCM_CELL_OBJECT ((x), (n)))
#define SCM_SET_SMOB_OBJECT_N(x,n,obj) (SCM_SET_CELL_OBJECT ((x), (n), (obj)))
#define SCM_SMOB_OBJECT_N_LOC(x,n) (SCM_CELL_OBJECT_LOC ((x), (n)))
/*#define SCM_SMOB_OBJECT_0(x) (SCM_SMOB_OBJECT_N ((x), 0))*/
#define SCM_SMOB_OBJECT_1(x) (SCM_SMOB_OBJECT_N ((x), 1))
#define SCM_SMOB_OBJECT_2(x) (SCM_SMOB_OBJECT_N ((x), 2))
#define SCM_SMOB_OBJECT_3(x) (SCM_SMOB_OBJECT_N ((x), 3))
/*#define SCM_SET_SMOB_OBJECT_0(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 0, (obj)))*/
#define SCM_SET_SMOB_OBJECT_1(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 1, (obj)))
#define SCM_SET_SMOB_OBJECT_2(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 2, (obj)))
#define SCM_SET_SMOB_OBJECT_3(x,obj) (SCM_SET_SMOB_OBJECT_N ((x), 3, (obj)))
#define SCM_SMOB_OBJECT_0_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 0)))
#define SCM_SMOB_OBJECT_1_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 1)))
#define SCM_SMOB_OBJECT_2_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 2)))
#define SCM_SMOB_OBJECT_3_LOC(x) (SCM_SMOB_OBJECT_N_LOC ((x), 3)))
#define SCM_SMOB_OBJECT(x) (SCM_SMOB_OBJECT_1 (x))
#define SCM_SET_SMOB_OBJECT(x,obj) (SCM_SET_SMOB_OBJECT_1 ((x), (obj)))
#define SCM_SMOB_OBJECT_LOC(x) (SCM_SMOB_OBJECT_1_LOC (x)))
#define SCM_SMOB_OBJECT(x) (SCM_CELL_OBJECT_1 (x))
#define SCM_SMOB_OBJECT_2(x) (SCM_CELL_OBJECT_2 (x))
#define SCM_SMOB_OBJECT_3(x) (SCM_CELL_OBJECT_3 (x))
#define SCM_SET_SMOB_OBJECT(x,obj) (SCM_SET_CELL_OBJECT_1 ((x), (obj)))
#define SCM_SET_SMOB_OBJECT_2(x,obj) (SCM_SET_CELL_OBJECT_2 ((x), (obj)))
#define SCM_SET_SMOB_OBJECT_3(x,obj) (SCM_SET_CELL_OBJECT_3 ((x), (obj)))
#define SCM_SMOB_OBJECT_LOC(x) (SCM_CELL_OBJECT_LOC ((x), 1))
#define SCM_SMOB_OBJECT_2_LOC(x) (SCM_CELL_OBJECT_LOC ((x), 2))
#define SCM_SMOB_OBJECT_3_LOC(x) (SCM_CELL_OBJECT_LOC ((x), 3))
#define SCM_TC2SMOBNUM(x) (0x0ff & ((x) >> 8))
#define SCM_SMOBNUM(x) (SCM_TC2SMOBNUM (SCM_CELL_TYPE (x)))
@ -159,7 +179,6 @@ while (0)
SCM_API long scm_numsmob;
SCM_API scm_smob_descriptor scm_smobs[];
SCM_API void scm_i_set_smob_flags (SCM x, scm_t_bits data);
SCM_API void scm_i_finalize_smob (GC_PTR obj, GC_PTR data);