From 8f5c053bd8649147d4e92c181a01d9053cf9b6cc Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 4 Mar 2014 00:28:39 +0900 Subject: [PATCH] add display function API --- include/picrin.h | 9 +++++++-- src/write.c | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/include/picrin.h b/include/picrin.h index 119c71ec..cbe33262 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -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) } diff --git a/src/write.c b/src/write.c index 2fbd6b7a..97076c0d 100644 --- a/src/write.c +++ b/src/write.c @@ -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, ...) {