From f89b0a7adf9260fee39dd82e756edfabcdf1a668 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 17 Nov 2013 01:11:57 -0500 Subject: [PATCH 4/6] Make port alists accessible from Scheme. * libguile/ports.c (scm_i_port_alist, scm_i_set_port_alist_x): Make these available from Scheme, as '%port-alist' and '%set-port-alist!'. Validate port argument. * libguile/ports.h (scm_i_set_port_alist_x): Change return type from 'void' to 'SCM'. --- libguile/ports.c | 17 +++++++++++++---- libguile/ports.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libguile/ports.c b/libguile/ports.c index 6f219d6..030090c 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -254,17 +254,26 @@ scm_i_clear_pending_eof (SCM port) SCM_PORT_GET_INTERNAL (port)->pending_eof = 0; } -SCM -scm_i_port_alist (SCM port) +SCM_DEFINE (scm_i_port_alist, "%port-alist", 1, 0, 0, + (SCM port), + "Return the alist associated with @var{port}.") +#define FUNC_NAME s_scm_i_port_alist { + SCM_VALIDATE_OPPORT (1, port); return SCM_PORT_GET_INTERNAL (port)->alist; } +#undef FUNC_NAME -void -scm_i_set_port_alist_x (SCM port, SCM alist) +SCM_DEFINE (scm_i_set_port_alist_x, "%set-port-alist!", 2, 0, 0, + (SCM port, SCM alist), + "Set the alist associated with @var{port} to @var{alist}.") +#define FUNC_NAME s_scm_i_set_port_alist_x { + SCM_VALIDATE_OPPORT (1, port); SCM_PORT_GET_INTERNAL (port)->alist = alist; + return SCM_UNSPECIFIED; } +#undef FUNC_NAME diff --git a/libguile/ports.h b/libguile/ports.h index 39317f8..c8d08df 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -318,7 +318,7 @@ SCM_API SCM scm_set_port_column_x (SCM port, SCM line); SCM_API SCM scm_port_filename (SCM port); SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename); SCM_INTERNAL SCM scm_i_port_alist (SCM port); -SCM_INTERNAL void scm_i_set_port_alist_x (SCM port, SCM alist); +SCM_INTERNAL SCM scm_i_set_port_alist_x (SCM port, SCM alist); SCM_INTERNAL const char *scm_i_default_port_encoding (void); SCM_INTERNAL void scm_i_set_default_port_encoding (const char *); SCM_INTERNAL void scm_i_set_port_encoding_x (SCM port, const char *str); -- 1.7.5.4