rename I/O functions

This commit is contained in:
Yuichi Nishiwaki
2016-06-20 04:49:01 +09:00
parent a1116d39eb
commit 9515060b00
22 changed files with 975 additions and 1017 deletions
+7 -24
View File
@@ -23,33 +23,16 @@ pic_value pic_eval(pic_state *, pic_value program, const char *lib);
void pic_load(pic_state *, pic_value port);
void pic_load_cstr(pic_state *, const char *);
#if PIC_USE_WRITE
void pic_printf(pic_state *, const char *fmt, ...);
void pic_fprintf(pic_state *, pic_value port, const char *fmt, ...);
void pic_vfprintf(pic_state *, pic_value port, const char *fmt, va_list ap);
#endif
/* extra xfile methods */
xFILE *xfile_xstdin(pic_state *);
xFILE *xfile_xstdout(pic_state *);
xFILE *xfile_xstderr(pic_state *);
#define xstdin (xfile_xstdin(pic))
#define xstdout (xfile_xstdout(pic))
#define xstderr (xfile_xstderr(pic))
#if PIC_USE_STDIO
xFILE *xfopen_file(pic_state *, FILE *, const char *mode);
#endif
xFILE *xfopen_buf(pic_state *, const char *buf, int len, const char *mode);
int xfget_buf(pic_state *, xFILE *file, const char **buf, int *len);
xFILE *xfopen_null(pic_state *, const char *mode);
/* port manipulation */
#define pic_stdin(pic) pic_funcall(pic, "picrin.base", "current-input-port", 0)
#define pic_stdout(pic) pic_funcall(pic, "picrin.base", "current-output-port", 0)
#define pic_stderr(pic) pic_funcall(pic, "picrin.base", "current-error-port", 0)
#if PIC_USE_STDIO
pic_value pic_fopen(pic_state *, FILE *, const char *mode);
#endif
pic_value pic_fmemopen(pic_state *, const char *buf, int len, const char *mode);
int pic_fgetbuf(pic_state *, pic_value port, const char **buf, int *len);
/* utility macros */
#define pic_for_each(var, list, it) \
@@ -98,7 +81,7 @@ xFILE *xfopen_null(pic_state *, const char *mode);
void pic_warnf(pic_state *, const char *, ...);
pic_value pic_get_backtrace(pic_state *);
#if PIC_USE_WRITE
void pic_print_error(pic_state *, xFILE *, pic_value err);
void pic_print_error(pic_state *, pic_value port, pic_value err);
#endif
#if defined(__cplusplus)
+7 -10
View File
@@ -5,10 +5,7 @@
extern "C" {
#endif
#define XBUFSIZ 1024
#define XOPEN_MAX 1024
struct xFILE {
struct file {
/* buffer */
char buf[1]; /* fallback buffer */
long cnt; /* characters left */
@@ -26,12 +23,12 @@ struct xFILE {
};
enum {
X_READ = 01,
X_WRITE = 02,
X_UNBUF = 04,
X_EOF = 010,
X_ERR = 020,
X_LNBUF = 040
FILE_READ = 01,
FILE_WRITE = 02,
FILE_UNBUF = 04,
FILE_EOF = 010,
FILE_ERR = 020,
FILE_LNBUF = 040
};
+1 -1
View File
@@ -127,7 +127,7 @@ struct error {
struct port {
OBJECT_HEADER
xFILE *file;
struct file *file;
};
struct checkpoint {
+1 -2
View File
@@ -11,7 +11,6 @@ extern "C" {
#include "picrin/private/khash.h"
#include "picrin/private/file.h"
#include "picrin/private/vm.h"
#include "picrin/private/gc.h"
@@ -61,7 +60,7 @@ struct pic_state {
khash_t(ltable) ltable;
struct list_head ireps;
xFILE files[XOPEN_MAX];
struct file files[PIC_OPEN_MAX];
bool gc_enable;
struct heap *heap;
+8
View File
@@ -36,6 +36,14 @@ void abort(void);
# define PIC_ABORT(pic) abort()
#endif
#ifndef PIC_OPEN_MAX
# define PIC_OPEN_MAX 1024
#endif
#ifndef PIC_BUFSIZ
# define PIC_BUFSIZ 1024
#endif
#ifndef PIC_ARENA_SIZE
# define PIC_ARENA_SIZE (8 * 1024)
#endif