1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Revert "Change dynwind flag enums to #defines, for greater portability"

This reverts commit b25aa0b937.
This commit is contained in:
Neil Jerram 2009-10-07 22:14:38 +01:00
parent 61aab1c375
commit 98241dc53f
4 changed files with 58 additions and 38 deletions

View file

@ -1276,7 +1276,21 @@ a-cont
@end lisp @end lisp
@end deffn @end deffn
@deftypefn {C Function} void scm_dynwind_begin (int flags) @deftp {C Type} scm_t_dynwind_flags
This is an enumeration of several flags that modify the behavior of
@code{scm_dynwind_begin}. The flags are listed in the following
table.
@table @code
@item SCM_F_DYNWIND_REWINDABLE
The dynamic context is @dfn{rewindable}. This means that it can be
reentered non-locally (via the invokation of a continuation). The
default is that a dynwind context can not be reentered non-locally.
@end table
@end deftp
@deftypefn {C Function} void scm_dynwind_begin (scm_t_dynwind_flags flags)
The function @code{scm_dynwind_begin} starts a new dynamic context and The function @code{scm_dynwind_begin} starts a new dynamic context and
makes it the `current' one. makes it the `current' one.
@ -1301,14 +1315,6 @@ or explicitly with @code{scm_dynwind_end}. You must make sure that a
dynwind context is indeed ended properly. If you fail to call dynwind context is indeed ended properly. If you fail to call
@code{scm_dynwind_end} for each @code{scm_dynwind_begin}, the behavior @code{scm_dynwind_end} for each @code{scm_dynwind_begin}, the behavior
is undefined. is undefined.
Possible flags are:
@table @code
@item SCM_F_DYNWIND_REWINDABLE
The dynamic context is @dfn{rewindable}. This means that it can be
reentered non-locally (via the invokation of a continuation). The
default is that a dynwind context can not be reentered non-locally.
@end table
@end deftypefn @end deftypefn
@deftypefn {C Function} void scm_dynwind_end () @deftypefn {C Function} void scm_dynwind_end ()
@ -1316,8 +1322,22 @@ End the current dynamic context explicitly and make the previous one
current. current.
@end deftypefn @end deftypefn
@deftypefn {C Function} void scm_dynwind_unwind_handler (void (*func)(void *), void *data, int flags) @deftp {C Type} scm_t_wind_flags
@deftypefnx {C Function} void scm_dynwind_unwind_handler_with_scm (void (*func)(SCM), SCM data, int flags) This is an enumeration of several flags that modify the behavior of
@code{scm_dynwind_unwind_handler} and
@code{scm_dynwind_rewind_handler}. The flags are listed in the
following table.
@table @code
@item SCM_F_WIND_EXPLICITLY
@vindex SCM_F_WIND_EXPLICITLY
The registered action is also carried out when the dynwind context is
entered or left locally.
@end table
@end deftp
@deftypefn {C Function} void scm_dynwind_unwind_handler (void (*func)(void *), void *data, scm_t_wind_flags flags)
@deftypefnx {C Function} void scm_dynwind_unwind_handler_with_scm (void (*func)(SCM), SCM data, scm_t_wind_flags flags)
Arranges for @var{func} to be called with @var{data} as its arguments Arranges for @var{func} to be called with @var{data} as its arguments
when the current context ends implicitly. If @var{flags} contains when the current context ends implicitly. If @var{flags} contains
@code{SCM_F_WIND_EXPLICITLY}, @var{func} is also called when the @code{SCM_F_WIND_EXPLICITLY}, @var{func} is also called when the
@ -1327,8 +1347,8 @@ The function @code{scm_dynwind_unwind_handler_with_scm} takes care that
@var{data} is protected from garbage collection. @var{data} is protected from garbage collection.
@end deftypefn @end deftypefn
@deftypefn {C Function} void scm_dynwind_rewind_handler (void (*func)(void *), void *data, int flags) @deftypefn {C Function} void scm_dynwind_rewind_handler (void (*func)(void *), void *data, scm_t_wind_flags flags)
@deftypefnx {C Function} void scm_dynwind_rewind_handler_with_scm (void (*func)(SCM), SCM data, int flags) @deftypefnx {C Function} void scm_dynwind_rewind_handler_with_scm (void (*func)(SCM), SCM data, scm_t_wind_flags flags)
Arrange for @var{func} to be called with @var{data} as its argument when Arrange for @var{func} to be called with @var{data} as its argument when
the current context is restarted by rewinding the stack. When @var{flags} the current context is restarted by rewinding the stack. When @var{flags}
contains @code{SCM_F_WIND_EXPLICITLY}, @var{func} is called immediately contains @code{SCM_F_WIND_EXPLICITLY}, @var{func} is called immediately
@ -1338,15 +1358,6 @@ The function @code{scm_dynwind_rewind_handler_with_scm} takes care that
@var{data} is protected from garbage collection. @var{data} is protected from garbage collection.
@end deftypefn @end deftypefn
The possible flags for the preceding four functions are as follows.
@table @code
@item SCM_F_WIND_EXPLICITLY
@vindex SCM_F_WIND_EXPLICITLY
The registered action is also carried out when the dynwind context is
entered or left locally.
@end table
@deftypefn {C Function} void scm_dynwind_free (void *mem) @deftypefn {C Function} void scm_dynwind_free (void *mem)
Arrange for @var{mem} to be freed automatically whenever the current Arrange for @var{mem} to be freed automatically whenever the current
context is exited, whether normally or non-locally. context is exited, whether normally or non-locally.

View file

@ -154,7 +154,7 @@ static scm_t_bits tc16_winder;
#define WINDER_MARK_P(w) (SCM_SMOB_FLAGS(w) & WINDER_F_MARK) #define WINDER_MARK_P(w) (SCM_SMOB_FLAGS(w) & WINDER_F_MARK)
void void
scm_dynwind_begin (int flags) scm_dynwind_begin (scm_t_dynwind_flags flags)
{ {
SCM f; SCM f;
SCM_NEWSMOB (f, tc16_frame, 0); SCM_NEWSMOB (f, tc16_frame, 0);
@ -192,7 +192,8 @@ scm_dynwind_end (void)
} }
void void
scm_dynwind_unwind_handler (void (*proc) (void *), void *data, int flags) scm_dynwind_unwind_handler (void (*proc) (void *), void *data,
scm_t_wind_flags flags)
{ {
SCM w; SCM w;
SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, (scm_t_bits) data); SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, (scm_t_bits) data);
@ -202,7 +203,8 @@ scm_dynwind_unwind_handler (void (*proc) (void *), void *data, int flags)
} }
void void
scm_dynwind_rewind_handler (void (*proc) (void *), void *data, int flags) scm_dynwind_rewind_handler (void (*proc) (void *), void *data,
scm_t_wind_flags flags)
{ {
SCM w; SCM w;
SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, (scm_t_bits) data); SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, (scm_t_bits) data);
@ -213,7 +215,8 @@ scm_dynwind_rewind_handler (void (*proc) (void *), void *data, int flags)
} }
void void
scm_dynwind_unwind_handler_with_scm (void (*proc) (SCM), SCM data, int flags) scm_dynwind_unwind_handler_with_scm (void (*proc) (SCM), SCM data,
scm_t_wind_flags flags)
{ {
SCM w; SCM w;
scm_t_bits fl = ((flags&SCM_F_WIND_EXPLICITLY)? WINDER_F_EXPLICIT : 0); scm_t_bits fl = ((flags&SCM_F_WIND_EXPLICITLY)? WINDER_F_EXPLICIT : 0);
@ -223,7 +226,8 @@ scm_dynwind_unwind_handler_with_scm (void (*proc) (SCM), SCM data, int flags)
} }
void void
scm_dynwind_rewind_handler_with_scm (void (*proc) (SCM), SCM data, int flags) scm_dynwind_rewind_handler_with_scm (void (*proc) (SCM), SCM data,
scm_t_wind_flags flags)
{ {
SCM w; SCM w;
SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, SCM_UNPACK (data)); SCM_NEWSMOB2 (w, tc16_winder, (scm_t_bits) proc, SCM_UNPACK (data));

View file

@ -43,21 +43,26 @@ SCM_INTERNAL void scm_init_dynwind (void);
SCM_API void scm_swap_bindings (SCM vars, SCM vals); SCM_API void scm_swap_bindings (SCM vars, SCM vals);
/* Flags for scm_dynwind_begin. */ typedef enum {
#define SCM_F_DYNWIND_REWINDABLE 1 SCM_F_DYNWIND_REWINDABLE = (1 << 0)
} scm_t_dynwind_flags;
/* Flags for scm_dynwind_unwind_handler(_with_scm) and typedef enum {
scm_dynwind_rewind_handler(_with_scm). */ SCM_F_WIND_EXPLICITLY = (1 << 0)
#define SCM_F_WIND_EXPLICITLY 1 } scm_t_wind_flags;
SCM_API void scm_dynwind_begin (int); SCM_API void scm_dynwind_begin (scm_t_dynwind_flags);
SCM_API void scm_dynwind_end (void); SCM_API void scm_dynwind_end (void);
SCM_API void scm_dynwind_unwind_handler (void (*) (void *), void *, int); SCM_API void scm_dynwind_unwind_handler (void (*func) (void *), void *data,
SCM_API void scm_dynwind_rewind_handler (void (*) (void *), void *, int); scm_t_wind_flags);
SCM_API void scm_dynwind_rewind_handler (void (*func) (void *), void *data,
scm_t_wind_flags);
SCM_API void scm_dynwind_unwind_handler_with_scm (void (*) (SCM), SCM, int); SCM_API void scm_dynwind_unwind_handler_with_scm (void (*func) (SCM), SCM data,
SCM_API void scm_dynwind_rewind_handler_with_scm (void (*) (SCM), SCM, int); scm_t_wind_flags);
SCM_API void scm_dynwind_rewind_handler_with_scm (void (*func) (SCM), SCM data,
scm_t_wind_flags);
SCM_API void scm_dynwind_free (void *mem); SCM_API void scm_dynwind_free (void *mem);

View file

@ -136,7 +136,7 @@ check_flag1 (const char *tag, void (*func)(void), int val)
SCM SCM
check_cont_body (void *data) check_cont_body (void *data)
{ {
int flags = (data? SCM_F_DYNWIND_REWINDABLE : 0); scm_t_dynwind_flags flags = (data? SCM_F_DYNWIND_REWINDABLE : 0);
int first; int first;
SCM val; SCM val;