Removed empty file genio.h and references to it.
[bpt/guile.git] / libguile / throw.c
index 3a19ffd..05274ca 100644 (file)
@@ -46,7 +46,6 @@
 
 #include <stdio.h>
 #include "_scm.h"
-#include "genio.h"
 #include "smob.h"
 #include "alist.h"
 #include "eval.h"
 #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_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)
@@ -95,7 +95,8 @@ printjb (SCM exp, SCM port, scm_print_state *pstate)
 {
   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 ;
 }
@@ -146,13 +147,11 @@ struct jmp_buf_and_retval /* use only on the stack, in scm_catch */
 
    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:
@@ -274,7 +273,7 @@ make_lazy_catch (struct lazy_catch *c)
 }
 
 #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:
@@ -526,32 +525,27 @@ scm_handle_by_throw (void *handler_data, SCM tag, SCM args)
 \f
 /* the Scheme-visible CATCH and LAZY-CATCH functions */
 
-GUILE_PROC(scm_catch, "catch", 3, 0, 0,
+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_ASSERT ((SCM_NIMP(tag) && SCM_SYMBOLP(tag)) || tag == SCM_BOOL_T,
+  SCM_ASSERT (SCM_SYMBOLP(tag) || tag == SCM_BOOL_T,
              tag, SCM_ARG1, FUNC_NAME);
 
   c.tag = tag;
@@ -569,15 +563,14 @@ this call to @code{catch}.")
 #undef FUNC_NAME
 
 
-GUILE_PROC(scm_lazy_catch, "lazy-catch", 3, 0, 0,
+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_ASSERT ((SCM_NIMP(tag) && SCM_SYMBOLP(tag))
-             || (tag == SCM_BOOL_T),
+  SCM_ASSERT (SCM_SYMBOLP(tag) || (tag == SCM_BOOL_T),
              tag, SCM_ARG1, FUNC_NAME);
 
   c.tag = tag;
@@ -599,24 +592,21 @@ GUILE_PROC(scm_lazy_catch, "lazy-catch", 3, 0, 0,
 \f
 /* throwing */
 
-GUILE_PROC(scm_throw, "throw", 1, 0, 1,
+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);
+  SCM_VALIDATE_SYMBOL (1,key);
   /* May return if handled by lazy catch. */
   return scm_ithrow (key, args, 1);
 }
 #undef FUNC_NAME
 
-
 SCM
 scm_ithrow (SCM key, SCM args, int noreturn)
 {
@@ -634,7 +624,7 @@ scm_ithrow (SCM key, SCM args, int noreturn)
        abort ();
 
       dynpair = SCM_CAR (winds);
-      if (SCM_NIMP (dynpair) && SCM_CONSP (dynpair))
+      if (SCM_CONSP (dynpair))
        {
          SCM this_key = SCM_CAR (dynpair);
 
@@ -723,21 +713,18 @@ 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,