* arbiters.c, async.c, regex-posix.c: Use new smob interface.
authorMikael Djurfeldt <djurfeldt@nada.kth.se>
Sun, 23 May 1999 09:55:54 +0000 (09:55 +0000)
committerMikael Djurfeldt <djurfeldt@nada.kth.se>
Sun, 23 May 1999 09:55:54 +0000 (09:55 +0000)
libguile/arbiters.c
libguile/async.c

index a8788a7..febb261 100644 (file)
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include "_scm.h"
 #include "smob.h"
+#include "genio.h"
 
 #include "arbiters.h"
 
@@ -71,23 +72,14 @@ prinarb (exp, port, pstate)
   return !0;
 }
 
-static scm_smobfuns arbsmob =
-{
-  scm_markcdr, scm_free0, prinarb, 0
-};
-
 SCM_PROC(s_make_arbiter, "make-arbiter", 1, 0, 0, scm_make_arbiter);
 
 SCM 
 scm_make_arbiter (name)
      SCM name;
 {
-  register SCM z;
-  SCM_NEWCELL (z);
-  SCM_DEFER_INTS;
-  SCM_SETCDR (z, name);
-  SCM_SETCAR (z, scm_tc16_arbiter);
-  SCM_ALLOW_INTS;
+  SCM z;
+  SCM_NEWSMOB (z, scm_tc16_arbiter, name);
   return z;
 }
 
@@ -129,7 +121,9 @@ scm_release_arbiter (arb)
 void
 scm_init_arbiters ()
 {
-  scm_tc16_arbiter = scm_newsmob (&arbsmob);
+  scm_tc16_arbiter = scm_make_smob_type ("arbiter", 0);
+  scm_set_smob_mark (scm_tc16_arbiter, scm_markcdr);
+  scm_set_smob_print (scm_tc16_arbiter, prinarb);
+
 #include "arbiters.x"
 }
-
index d173906..b7b138c 100644 (file)
@@ -263,21 +263,6 @@ scm_switch ()
 
 \f
 
-static int print_async SCM_P ((SCM exp, SCM port, scm_print_state *pstate));
-
-static int
-print_async (exp, port, pstate)
-     SCM exp;
-     SCM port;
-     scm_print_state *pstate;
-{
-  scm_puts ("#<async ", port);
-  scm_intprint(exp, 16, port);
-  scm_putc('>', port);
-  return 1;
-}
-
-
 static SCM mark_async SCM_P ((SCM obj));
 
 static SCM
@@ -289,29 +274,6 @@ mark_async (obj)
   return it->thunk;
 }
 
-
-static scm_sizet free_async SCM_P ((SCM obj));
-
-static scm_sizet
-free_async (obj)
-     SCM obj;
-{
-  struct scm_async * it;
-  it = SCM_ASYNC (obj);
-  scm_must_free ((char *)it);
-  return (sizeof (*it));
-}
-
-
-static scm_smobfuns  async_smob =
-{
-  mark_async,
-  free_async,
-  print_async,
-  0
-};
-
-
 \f
 
 SCM_PROC(s_async, "async", 1, 0, 0, scm_async);
@@ -321,17 +283,11 @@ scm_async (thunk)
      SCM thunk;
 {
   SCM it;
-  struct scm_async * async;
-
-  SCM_NEWCELL (it);
-  SCM_DEFER_INTS;
-  SCM_SETCDR (it, SCM_EOL);
-  async = (struct scm_async *)scm_must_malloc (sizeof (*async), s_async);
+  struct scm_async * async
+    = (struct scm_async *) scm_must_malloc (sizeof (*async), s_async);
   async->got_it = 0;
   async->thunk = thunk;
-  SCM_SETCDR (it, (SCM)async);
-  SCM_SETCAR (it, (SCM)scm_tc16_async);
-  SCM_ALLOW_INTS;
+  SCM_NEWSMOB (it, scm_tc16_async, async);
   return it;
 }
 
@@ -517,8 +473,8 @@ void
 scm_init_async ()
 {
   SCM a_thunk;
-  scm_tc16_async = scm_newsmob (&async_smob);
-
+  scm_tc16_async = scm_make_smob_type ("async", sizeof (struct scm_async));
+  scm_set_smob_mark (scm_tc16_async, mark_async);
   scm_gc_vcell = scm_sysintern ("gc-thunk", SCM_BOOL_F);
   a_thunk = scm_make_gsubr ("%gc-thunk", 0, 0, 0, scm_sys_gc_async_thunk);
   scm_gc_async = scm_system_async (a_thunk);