mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-30 15:00:21 +02:00
("scm_new_port_table_entry"): return a boxed SCM in
stead of scm_t_port*. The function now takes a tag argument.
This commit is contained in:
parent
395b0a341f
commit
da220f2794
6 changed files with 27 additions and 28 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2002-08-09 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
||||||
|
|
||||||
|
* ports.c ("scm_new_port_table_entry"): return a boxed SCM in
|
||||||
|
stead of scm_t_port*. The function now takes a tag argument.
|
||||||
|
|
||||||
2002-08-08 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
2002-08-08 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
||||||
|
|
||||||
* gc.h: add scm_debug_cells_gc_interval to public interface
|
* gc.h: add scm_debug_cells_gc_interval to public interface
|
||||||
|
|
|
@ -437,10 +437,10 @@ scm_fdes_to_port (int fdes, char *mode, SCM name)
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
pt = scm_new_port_table_entry ();
|
|
||||||
port = scm_cell (scm_tc16_fport | mode_bits, (scm_t_bits) pt);
|
port = scm_new_port_table_entry (scm_tc16_fport);
|
||||||
pt->port = port;
|
SCM_SET_CELL_TYPE(port, scm_tc16_fport | mode_bits);
|
||||||
|
pt = SCM_PTAB_ENTRY(port);
|
||||||
{
|
{
|
||||||
scm_t_fport *fp
|
scm_t_fport *fp
|
||||||
= (scm_t_fport *) scm_gc_malloc (sizeof (scm_t_fport), "file port");
|
= (scm_t_fport *) scm_gc_malloc (sizeof (scm_t_fport), "file port");
|
||||||
|
|
|
@ -452,10 +452,11 @@ long scm_port_table_size = 0; /* Number of ports in scm_port_table. */
|
||||||
long scm_port_table_room = 20; /* Size of the array. */
|
long scm_port_table_room = 20; /* Size of the array. */
|
||||||
|
|
||||||
|
|
||||||
scm_t_port *
|
SCM
|
||||||
scm_new_port_table_entry (void)
|
scm_new_port_table_entry (scm_t_bits tag)
|
||||||
#define FUNC_NAME "scm_new_port_table_entry"
|
#define FUNC_NAME "scm_new_port_table_entry"
|
||||||
{
|
{
|
||||||
|
SCM z = scm_cell (SCM_EOL, SCM_EOL);
|
||||||
scm_t_port *entry = (scm_t_port *) scm_gc_calloc (sizeof (scm_t_port), "port");
|
scm_t_port *entry = (scm_t_port *) scm_gc_calloc (sizeof (scm_t_port), "port");
|
||||||
if (scm_port_table_size == scm_port_table_room)
|
if (scm_port_table_size == scm_port_table_room)
|
||||||
{
|
{
|
||||||
|
@ -468,17 +469,19 @@ scm_new_port_table_entry (void)
|
||||||
scm_port_table_room *= 2;
|
scm_port_table_room *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->port = SCM_EOL;
|
|
||||||
entry->entry = scm_port_table_size;
|
entry->entry = scm_port_table_size;
|
||||||
|
|
||||||
entry->file_name = SCM_BOOL_F;
|
entry->file_name = SCM_BOOL_F;
|
||||||
entry->rw_active = SCM_PORT_NEITHER;
|
entry->rw_active = SCM_PORT_NEITHER;
|
||||||
|
|
||||||
|
|
||||||
scm_port_table[scm_port_table_size] = entry;
|
scm_port_table[scm_port_table_size] = entry;
|
||||||
scm_port_table_size++;
|
scm_port_table_size++;
|
||||||
|
|
||||||
return entry;
|
entry->port = z;
|
||||||
|
SCM_SET_CELL_TYPE(z, tag);
|
||||||
|
SCM_SETPTAB_ENTRY(z, entry);
|
||||||
|
|
||||||
|
return z;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -1521,13 +1524,10 @@ scm_void_port (char *mode_str)
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
{
|
{
|
||||||
int mode_bits = scm_mode_bits (mode_str);
|
int mode_bits = scm_mode_bits (mode_str);
|
||||||
scm_t_port * pt = scm_new_port_table_entry ();
|
SCM answer = scm_new_port_table_entry (scm_tc16_void_port);
|
||||||
SCM answer;
|
scm_t_port * pt = SCM_PTAB_ENTRY(answer);
|
||||||
|
|
||||||
scm_port_non_buffer (pt);
|
scm_port_non_buffer (pt);
|
||||||
answer = scm_cell (scm_tc16_void_port, 0);
|
|
||||||
SCM_SETPTAB_ENTRY (answer, pt);
|
|
||||||
pt->port = answer;
|
|
||||||
|
|
||||||
SCM_SETSTREAM (answer, 0);
|
SCM_SETSTREAM (answer, 0);
|
||||||
SCM_SET_CELL_TYPE (answer, scm_tc16_void_port | mode_bits);
|
SCM_SET_CELL_TYPE (answer, scm_tc16_void_port | mode_bits);
|
||||||
|
|
|
@ -257,7 +257,7 @@ SCM_API SCM scm_current_load_port (void);
|
||||||
SCM_API SCM scm_set_current_input_port (SCM port);
|
SCM_API SCM scm_set_current_input_port (SCM port);
|
||||||
SCM_API SCM scm_set_current_output_port (SCM port);
|
SCM_API SCM scm_set_current_output_port (SCM port);
|
||||||
SCM_API SCM scm_set_current_error_port (SCM port);
|
SCM_API SCM scm_set_current_error_port (SCM port);
|
||||||
SCM_API scm_t_port * scm_new_port_table_entry (void);
|
SCM_API SCM scm_new_port_table_entry (scm_t_bits tag);
|
||||||
SCM_API void scm_remove_from_port_table (SCM port);
|
SCM_API void scm_remove_from_port_table (SCM port);
|
||||||
SCM_API void scm_grow_port_cbuf (SCM port, size_t requested);
|
SCM_API void scm_grow_port_cbuf (SCM port, size_t requested);
|
||||||
SCM_API SCM scm_pt_size (void);
|
SCM_API SCM scm_pt_size (void);
|
||||||
|
|
|
@ -281,14 +281,10 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
|
||||||
scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL);
|
scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL);
|
||||||
|
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
pt = scm_new_port_table_entry ();
|
z = scm_new_port_table_entry (scm_tc16_strport);
|
||||||
z = scm_cell (scm_tc16_strport | modes, 0);
|
pt = SCM_PTAB_ENTRY(z);
|
||||||
|
|
||||||
SCM_SETPTAB_ENTRY (z, pt);
|
|
||||||
pt->port = z;
|
|
||||||
|
|
||||||
|
|
||||||
SCM_SETSTREAM (z, SCM_UNPACK (str));
|
SCM_SETSTREAM (z, SCM_UNPACK (str));
|
||||||
|
SCM_SET_CELL_TYPE(z, scm_tc16_strport|modes);
|
||||||
pt->write_buf = pt->read_buf = SCM_STRING_UCHARS (str);
|
pt->write_buf = pt->read_buf = SCM_STRING_UCHARS (str);
|
||||||
pt->read_pos = pt->write_pos = pt->read_buf + SCM_INUM (pos);
|
pt->read_pos = pt->write_pos = pt->read_buf + SCM_INUM (pos);
|
||||||
pt->write_buf_size = pt->read_buf_size = str_len;
|
pt->write_buf_size = pt->read_buf_size = str_len;
|
||||||
|
|
|
@ -191,12 +191,10 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0,
|
||||||
SCM_VALIDATE_STRING (2, modes);
|
SCM_VALIDATE_STRING (2, modes);
|
||||||
|
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
pt = scm_new_port_table_entry ();
|
z = scm_new_port_table_entry (scm_tc16_sfport);
|
||||||
scm_port_non_buffer (pt);
|
scm_port_non_buffer (pt);
|
||||||
z = scm_cell (scm_tc16_sfport | scm_mode_bits (SCM_STRING_CHARS (modes)), 0);
|
SCM_SET_CELL_TYPE (z, scm_tc16_sfport | scm_mode_bits (SCM_STRING_CHARS (modes)));
|
||||||
SCM_SETPTAB_ENTRY (z, pt);
|
|
||||||
pt->port = z;
|
|
||||||
|
|
||||||
SCM_SETSTREAM (z, SCM_UNPACK (pv));
|
SCM_SETSTREAM (z, SCM_UNPACK (pv));
|
||||||
SCM_ALLOW_INTS;
|
SCM_ALLOW_INTS;
|
||||||
return z;
|
return z;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue