#include "stacks.h"
#include "fluids.h"
-#include "scm_validate.h"
+#include "validate.h"
#include "throw.h"
\f
/* the jump buffer data structure */
static int scm_tc16_jmpbuffer;
-#define SCM_JMPBUFP(O) (SCM_NIMP(O) && (SCM_TYP16(O) == scm_tc16_jmpbuffer))
-#define JBACTIVE(O) (SCM_CAR (O) & (1L << 16L))
-#define ACTIVATEJB(O) (SCM_SETOR_CAR (O, (1L << 16L)))
-#define DEACTIVATEJB(O) (SCM_SETAND_CAR (O, ~(1L << 16L)))
+#define SCM_JMPBUFP(OBJ) (SCM_NIMP(OBJ) && (SCM_TYP16(OBJ) == scm_tc16_jmpbuffer))
+
+#define JBACTIVE(OBJ) (SCM_UNPACK_CAR (OBJ) & (1L << 16L))
+#define ACTIVATEJB(OBJ) (SCM_SETOR_CAR (OBJ, (1L << 16L)))
+#define DEACTIVATEJB(OBJ) (SCM_SETAND_CAR (OBJ, ~(1L << 16L)))
#ifndef DEBUG_EXTENSIONS
-#define JBJMPBUF(O) ((jmp_buf*)SCM_CDR (O) )
+#define JBJMPBUF(OBJ) ((jmp_buf*)SCM_CDR (OBJ) )
#define SETJBJMPBUF SCM_SETCDR
#else
-#define SCM_JBDFRAME(O) ((scm_debug_frame*)SCM_CAR (SCM_CDR (O)) )
-#define JBJMPBUF(O) ((jmp_buf*)SCM_CDR (SCM_CDR (O)) )
-#define SCM_SETJBDFRAME(O,X) SCM_SETCAR (SCM_CDR (O), (SCM)(X))
-#define SETJBJMPBUF(O,X) SCM_SETCDR(SCM_CDR (O), X)
+#define SCM_JBDFRAME(OBJ) ((scm_debug_frame*)SCM_CAR (SCM_CDR (OBJ)) )
+#define JBJMPBUF(OBJ) ((jmp_buf*)SCM_CDR (SCM_CDR (OBJ)) )
+#define SCM_SETJBDFRAME(OBJ,X) SCM_SETCAR (SCM_CDR (OBJ), (SCM)(X))
+#define SETJBJMPBUF(OBJ,X) SCM_SETCDR(SCM_CDR (OBJ), X)
static scm_sizet
freejb (SCM jbsmob)
{
scm_puts ("#<jmpbuffer ", port);
scm_puts (JBACTIVE(exp) ? "(active) " : "(inactive) ", port);
- scm_intprint((SCM) JBJMPBUF(exp), 16, port);
+ scm_intprint(SCM_UNPACK ( JBJMPBUF(exp) ), 16, port);
+
scm_putc ('>', port);
return 1 ;
}
BODY is a pointer to a C function which runs the body of the catch;
this is the code you can throw from. We call it like this:
- BODY (BODY_DATA, JMPBUF)
+ BODY (BODY_DATA)
where:
BODY_DATA is just the BODY_DATA argument we received; we pass it
through to BODY as its first argument. The caller can make
BODY_DATA point to anything useful that BODY might need.
- JMPBUF is the Scheme jmpbuf object corresponding to this catch,
- which we have just created and initialized.
HANDLER is a pointer to a C function to deal with a throw to TAG,
should one occur. We call it like this:
}
#define SCM_LAZY_CATCH_P(obj) \
- (SCM_NIMP (obj) && (SCM_CAR (obj) == tc16_lazy_catch))
+ (SCM_NIMP (obj) && (SCM_UNPACK_CAR (obj) == tc16_lazy_catch))
/* Exactly like scm_internal_catch, except:
SCM_DEFINE (scm_catch, "catch", 3, 0, 0,
(SCM tag, SCM thunk, SCM handler),
-"Invoke @var{thunk} in the dynamic context of @var{handler} for
-exceptions matching @var{key}. If thunk throws to the symbol @var{key},
-then @var{handler} is invoked this way:
-
-@example
-(handler key args ...)
-@end example
-
-@var{key} is a symbol or #t.
-
-@var{thunk} takes no arguments. If @var{thunk} returns normally, that
-is the return value of @code{catch}.
-
-Handler is invoked outside the scope of its own @code{catch}. If
-@var{handler} again throws to the same key, a new handler from further
-up the call chain is invoked.
-
-If the key is @code{#t}, then a throw to @emph{any} symbol will match
-this call to @code{catch}.")
+ "Invoke @var{thunk} in the dynamic context of @var{handler} for\n"
+ "exceptions matching @var{key}. If thunk throws to the symbol @var{key},\n"
+ "then @var{handler} is invoked this way:\n\n"
+ "@example\n"
+ "(handler key args ...)\n"
+ "@end example\n\n"
+ "@var{key} is a symbol or #t.\n\n"
+ "@var{thunk} takes no arguments. If @var{thunk} returns normally, that\n"
+ "is the return value of @code{catch}.\n\n"
+ "Handler is invoked outside the scope of its own @code{catch}. If\n"
+ "@var{handler} again throws to the same key, a new handler from further\n"
+ "up the call chain is invoked.\n\n"
+ "If the key is @code{#t}, then a throw to @emph{any} symbol will match\n"
+ "this call to @code{catch}.")
#define FUNC_NAME s_scm_catch
{
struct scm_body_thunk_data c;
SCM_DEFINE (scm_lazy_catch, "lazy-catch", 3, 0, 0,
(SCM tag, SCM thunk, SCM handler),
-"")
+ "")
#define FUNC_NAME s_scm_lazy_catch
{
struct scm_body_thunk_data c;
SCM_DEFINE (scm_throw, "throw", 1, 0, 1,
(SCM key, SCM args),
-"Invoke the catch form matching @var{key}, passing @var{args} to the
-@var{handler}.
-
-@var{key} is a symbol. It will match catches of the same symbol or of
-#t.
-
-If there is no handler at all, an error is signaled.")
+ "Invoke the catch form matching @var{key}, passing @var{args} to the\n"
+ "@var{handler}. \n\n"
+ "@var{key} is a symbol. It will match catches of the same symbol or of\n"
+ "#t.\n\n"
+ "If there is no handler at all, an error is signaled.")
#define FUNC_NAME s_scm_throw
{
SCM_VALIDATE_SYMBOL (1,key);
}
#undef FUNC_NAME
-
SCM
scm_ithrow (SCM key, SCM args, int noreturn)
{
void
scm_init_throw ()
{
-#ifdef DEBUG_EXTENSIONS
scm_tc16_jmpbuffer = scm_make_smob_type_mfpe ("jmpbuffer",
+#ifdef DEBUG_EXTENSIONS
sizeof (scm_cell),
NULL, /* mark */
freejb,
- printjb,
- NULL);
#else
- scm_tc16_jmpbuffer = scm_make_smob_type_mfpe ("jmpbuffer",
0,
NULL, /* mark */
- NULL
+ NULL,
+#endif
printjb,
NULL);
-#endif
tc16_lazy_catch = scm_make_smob_type_mfpe ("lazy-catch", 0,
NULL,