return port;
}
-static SCM
-bip_mark (SCM port)
-{
- /* Mark the underlying bytevector. */
- return (SCM_PACK (SCM_STREAM (port)));
-}
-
static int
bip_fill_input (SCM port)
{
scm_make_port_type ("r6rs-bytevector-input-port", bip_fill_input,
NULL);
- scm_set_port_mark (bytevector_input_port_type, bip_mark);
scm_set_port_seek (bytevector_input_port_type, bip_seek);
}
#define SCM_CBP_CLOSE_PROC(_port) \
SCM_SIMPLE_VECTOR_REF (SCM_PACK (SCM_STREAM (_port)), 3)
-static SCM
-cbp_mark (SCM port)
-{
- /* Mark the underlying method and object vector. */
- if (SCM_OPENP (port))
- return SCM_PACK (SCM_STREAM (port));
- else
- return SCM_BOOL_F;
-}
-
static scm_t_off
cbp_seek (SCM port, scm_t_off offset, int whence)
#define FUNC_NAME "cbp_seek"
scm_make_port_type ("r6rs-custom-binary-input-port",
cbip_fill_input, NULL);
- scm_set_port_mark (custom_binary_input_port_type, cbp_mark);
scm_set_port_seek (custom_binary_input_port_type, cbp_seek);
scm_set_port_close (custom_binary_input_port_type, cbp_close);
}
return (scm_values (scm_list_2 (port, bop_proc)));
}
-static size_t
-bop_free (SCM port)
-{
- /* The port itself is necessarily freed _after_ the bop proc, since the bop
- proc holds a reference to it. Thus we can safely free the internal
- buffer when the bop becomes unreferenced. */
- scm_t_bop_buffer *buf;
-
- buf = SCM_BOP_BUFFER (port);
- if (buf->buffer)
- scm_gc_free (buf->buffer, buf->total_len, SCM_GC_BOP);
-
- scm_gc_free (buf, sizeof (* buf), SCM_GC_BOP);
-
- return 0;
-}
-
/* Write SIZE octets from DATA to PORT. */
static void
bop_write (SCM port, const void *data, size_t size)
return bv;
}
-SCM_SMOB_MARK (bytevector_output_port_procedure, bop_proc_mark,
- bop_proc)
-{
- /* Mark the port associated with BOP_PROC. */
- return (SCM_PACK (SCM_SMOB_DATA (bop_proc)));
-}
-
-
SCM_DEFINE (scm_open_bytevector_output_port,
"open-bytevector-output-port", 0, 1, 0,
(SCM transcoder),
NULL, bop_write);
scm_set_port_seek (bytevector_output_port_type, bop_seek);
- scm_set_port_free (bytevector_output_port_type, bop_free);
}
\f
scm_make_port_type ("r6rs-custom-binary-output-port",
NULL, cbop_write);
- scm_set_port_mark (custom_binary_output_port_type, cbp_mark);
scm_set_port_seek (custom_binary_output_port_type, cbp_seek);
scm_set_port_close (custom_binary_output_port_type, cbp_close);
}