add display function API

This commit is contained in:
Yuichi Nishiwaki 2014-03-04 00:28:39 +09:00
parent 5b2898ae5c
commit 8f5c053bd8
2 changed files with 24 additions and 5 deletions

View File

@ -207,9 +207,14 @@ void pic_warn(pic_state *, const char *);
const char *pic_errmsg(pic_state *);
pic_value pic_debug(pic_state *, pic_value);
pic_value pic_fdebug(pic_state *, pic_value, xFILE *);
pic_value pic_write(pic_state *, pic_value); /* returns given obj */
pic_value pic_fwrite(pic_state *, pic_value, xFILE *);
void pic_printf(pic_state *, const char *, ...);
pic_value pic_display(pic_state *, pic_value);
pic_value pic_fdisplay(pic_state *, pic_value, xFILE *);
/* obsoleted macros */
#define pic_debug(pic,obj) pic_write(pic,obj)
#define pic_fdebug(pic,obj,file) pic_fwrite(pic,obj,file)
#if defined(__cplusplus)
}

View File

@ -385,19 +385,33 @@ display(pic_state *pic, pic_value obj, xFILE *file)
}
pic_value
pic_debug(pic_state *pic, pic_value obj)
pic_write(pic_state *pic, pic_value obj)
{
return pic_fdebug(pic, obj, xstdout);
return pic_fwrite(pic, obj, xstdout);
}
pic_value
pic_fdebug(pic_state *pic, pic_value obj, xFILE *file)
pic_fwrite(pic_state *pic, pic_value obj, xFILE *file)
{
write(pic, obj, file);
xfflush(file);
return obj;
}
pic_value
pic_display(pic_state *pic, pic_value obj)
{
return pic_fdisplay(pic, obj, xstdout);
}
pic_value
pic_fdisplay(pic_state *pic, pic_value obj, xFILE *file)
{
display(pic, obj, file);
xfflush(file);
return obj;
}
void
pic_printf(pic_state *pic, const char *fmt, ...)
{