add accessors of stdio ports

This commit is contained in:
Yuichi Nishiwaki 2014-01-13 00:51:19 +09:00
parent 3fb407329f
commit 1c14feffa4
2 changed files with 14 additions and 0 deletions

View File

@ -27,4 +27,8 @@ struct pic_port {
pic_value pic_eof_object();
struct pic_port *pic_stdin(pic_state *);
struct pic_port *pic_stdout(pic_state *);
struct pic_port *pic_stderr(pic_state *);
#endif

View File

@ -17,6 +17,16 @@ pic_eof_object()
return v;
}
struct pic_port *
pic_stdin(pic_state *pic)
{
struct pic_proc *proc;
proc = pic_proc_ptr(pic_ref(pic, "current-input-port"));
return pic_port_ptr(pic_apply(pic, proc, pic_nil_value()));
}
static void write_pair(pic_state *pic, struct pic_pair *pair);
static void write_str(pic_state *pic, struct pic_string *str);