Move the port alist from the hash table to the internal port structure.

* libguile/ports-internal.h (struct scm_port_internal): Add 'alist'
  member.

* libguile/ports.c (scm_i_port_alist, scm_i_set_port_alist_x): New
  internal functions.
  (scm_i_port_weak_hash): Update comment: the hash table is no longer
  used to store the port's alist.
  (scm_new_port_table_entry): Initialize 'alist'.  Store SCM_BOOL_F in
  the port weak hash, not SCM_EOL.

* libguile/ports.h (scm_i_port_alist, scm_i_set_port_alist_x): Add
  protoypes.

* libguile/read.c (set_port_read_option, init_read_options): Access the
  port's alist via 'scm_i_port_alist' and 'scm_i_set_port_alist_x'.
This commit is contained in:
Mark H Weaver 2013-03-31 19:52:31 -04:00
commit 05d7f76296
4 changed files with 25 additions and 13 deletions

View file

@ -241,6 +241,18 @@ scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM))
scm_ptobs[SCM_TC2PTOBNUM (tc)].input_waiting = input_waiting;
}
SCM
scm_i_port_alist (SCM port)
{
return SCM_PORT_GET_INTERNAL (port)->alist;
}
void
scm_i_set_port_alist_x (SCM port, SCM alist)
{
SCM_PORT_GET_INTERNAL (port)->alist = alist;
}
SCM_DEFINE (scm_char_ready_p, "char-ready?", 0, 1, 0,
@ -538,8 +550,7 @@ scm_i_dynwind_current_load_port (SCM port)
/*
We need a global registry of ports to flush them all at exit, and to
get all the ports matching a file descriptor. The associated values
are alists, where additional information can be associated with ports.
get all the ports matching a file descriptor.
*/
SCM scm_i_port_weak_hash;
@ -634,10 +645,12 @@ scm_new_port_table_entry (scm_t_bits tag)
entry->input_cd = pti; /* XXX pointer to the internal port structure */
entry->output_cd = NULL; /* XXX unused */
pti->alist = SCM_EOL;
SCM_SET_CELL_TYPE (z, tag);
SCM_SETPTAB_ENTRY (z, entry);
scm_hashq_set_x (scm_i_port_weak_hash, z, SCM_EOL);
scm_hashq_set_x (scm_i_port_weak_hash, z, SCM_BOOL_F);
/* For each new port, register a finalizer so that it port type's free
function can be invoked eventually. */