fluids.h exposes more of its interface, internally at least
authorAndy Wingo <wingo@pobox.com>
Fri, 19 Feb 2010 10:39:44 +0000 (11:39 +0100)
committerAndy Wingo <wingo@pobox.com>
Fri, 19 Feb 2010 11:10:11 +0000 (12:10 +0100)
* libguile/fluids.h (SCM_I_FLUID_P, SCM_I_FLUID_NUM)
  (SCM_I_DYNAMIC_STATE_P, SCM_I_DYNAMIC_STATE_FLUIDS): Expose these
  predicates and accessors, internally at least.
* libguile/fluids.c (IS_FLUID, FLUID_NUM, IS_DYNAMIC_STATE)
  (DYNAMIC_STATE_FLUIDS): Implement in terms of the exposed macros.

libguile/fluids.c
libguile/fluids.h

index c9ea68b..d493053 100644 (file)
@@ -65,11 +65,11 @@ static size_t allocated_fluids_len = 0;
 static size_t allocated_fluids_num = 0;
 static char *allocated_fluids = NULL;
 
-#define IS_FLUID(x)         (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_fluid)
-#define FLUID_NUM(x)        ((size_t)SCM_CELL_WORD_1(x))
+#define IS_FLUID(x)         SCM_I_FLUID_P (x)
+#define FLUID_NUM(x)        SCM_I_FLUID_NUM (x)
 
-#define IS_DYNAMIC_STATE(x) (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_dynamic_state)
-#define DYNAMIC_STATE_FLUIDS(x)        SCM_PACK (SCM_CELL_WORD_1 (x))
+#define IS_DYNAMIC_STATE(x) SCM_I_DYNAMIC_STATE_P (x)
+#define DYNAMIC_STATE_FLUIDS(x)        SCM_I_DYNAMIC_STATE_FLUIDS (x)
 #define SET_DYNAMIC_STATE_FLUIDS(x, y) SCM_SET_CELL_WORD_1 ((x), (SCM_UNPACK (y)))
 
 
index 7aefd47..0d61fd2 100644 (file)
    grow.
  */
 
-/* The fastest way to acces/modify the value of a fluid.  These macros
-   do no error checking at all.  The first argument is the index
-   number of the fluid, obtained via SCM_FLUID_NUM, not the fluid
-   itself.  You must make sure that the fluid remains protected as
-   long you use its number since numbers of unused fluids are reused
-   eventually.
-*/
+#define SCM_I_FLUID_P(x)          (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_fluid)
+#define SCM_I_FLUID_NUM(x)        ((size_t)SCM_CELL_WORD_1(x))
 
 SCM_API SCM scm_make_fluid (void);
 SCM_API int scm_is_fluid (SCM obj);
@@ -80,6 +75,9 @@ SCM_API SCM scm_with_fluid (SCM fluid, SCM val, SCM thunk);
 
 SCM_API void scm_dynwind_fluid (SCM fluid, SCM value);
 
+#define SCM_I_DYNAMIC_STATE_P(x) (!SCM_IMP (x) && SCM_TYP7 (x) == scm_tc7_dynamic_state)
+#define SCM_I_DYNAMIC_STATE_FLUIDS(x)        SCM_PACK (SCM_CELL_WORD_1 (x))
+
 SCM_API SCM scm_make_dynamic_state (SCM parent);
 SCM_API SCM scm_dynamic_state_p (SCM obj);
 SCM_API int scm_is_dynamic_state (SCM obj);