[uim-commit] r1824 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Thu Oct 6 11:10:41 PDT 2005
Author: kzk
Date: 2005-10-06 11:10:39 -0700 (Thu, 06 Oct 2005)
New Revision: 1824
Modified:
branches/r5rs/sigscheme/datas.c
branches/r5rs/sigscheme/debug.c
branches/r5rs/sigscheme/error.c
branches/r5rs/sigscheme/io.c
branches/r5rs/sigscheme/read.c
branches/r5rs/sigscheme/sigschemetype.h
Log:
* Port related accessor reorganization. Not to use the
word "PORTINFO", because this is for internal representation.
* sigscheme/sigschemetype.h
- (SCM_PORTINFO_PORTTYPE,
SCM_PORTINFO_FILE,
SCM_PORTINFO_FILENAME,
SCM_PORTINFO_LINE,
SCM_PORTINFO_STR,
SCM_PORTINFO_STR_CURRENT,
SCM_PORTINFO_UNGOTTENCHAR): removed
- (SCM_PORT_PORTTYPE,
SCM_PORT_SET_PORTTYPE,
SCM_PORT_UNGOTTENCHAR,
SCM_PORT_SET_UNGOTTENCHAR,
SCM_PORT_FILE,
SCM_PORT_SET_FILE,
SCM_PORT_FILENAME,
SCM_PORT_SET_FILENAME,
SCM_PORT_LINE,
SCM_PORT_SET_LINE,
SCM_PORT_STR,
SCM_PORT_SET_STR,
SCM_PORT_STR_CURRENTPOS,
SCM_PORT_SET_STR_CURRENTPOS): new macro
- (str_currentpos): renamed from str_current
* sigscheme/io.c
- Ditto
* sigscheme/read.c
- Ditto
* sigscheme/debug.c
- Ditto
* sigscheme/error.c
- Ditto
* sigscheme/datas.c
- Ditto
- (Scm_NewStringPort,
Scm_NewFilePort): use accessor macro instead of directly
accessing port_info.
Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/datas.c 2005-10-06 18:10:39 UTC (rev 1824)
@@ -601,14 +601,14 @@
case ScmPort:
/* handle each port type */
- switch (SCM_PORTINFO_PORTTYPE(obj)) {
+ switch (SCM_PORT_PORTTYPE(obj)) {
case PORT_FILE:
- if (SCM_PORTINFO_FILENAME(obj))
- free(SCM_PORTINFO_FILENAME(obj));
+ if (SCM_PORT_FILENAME(obj))
+ free(SCM_PORT_FILENAME(obj));
break;
case PORT_STRING:
- if (SCM_PORTINFO_STR(obj))
- free(SCM_PORTINFO_STR(obj));
+ if (SCM_PORT_STR(obj))
+ free(SCM_PORT_STR(obj));
break;
}
/* free port info */
@@ -812,12 +812,13 @@
SCM_ENTYPE_PORT(obj);
SCM_PORT_SET_PORTDIRECTION(obj, pdirection);
- pinfo->port_type = PORT_FILE;
- pinfo->info.file_port.file = file;
- pinfo->info.file_port.filename = strdup(filename);
- pinfo->info.file_port.line = 0;
- pinfo->ungottenchar = 0;
+
SCM_PORT_SET_PORTINFO(obj, pinfo);
+ SCM_PORT_SET_PORTTYPE(obj, PORT_FILE);
+ SCM_PORT_SET_FILE(obj, file);
+ SCM_PORT_SET_FILENAME(obj, strdup(filename));
+ SCM_PORT_SET_LINE(obj, 0);
+ SCM_PORT_SET_UNGOTTENCHAR(obj, 0);
return obj;
}
@@ -831,11 +832,12 @@
SCM_ENTYPE_PORT(obj);
SCM_PORT_SET_PORTDIRECTION(obj, PORT_INPUT);
- pinfo->port_type = PORT_STRING;
- pinfo->info.str_port.port_str = strdup(str);
- pinfo->info.str_port.str_current = pinfo->info.str_port.port_str;
- pinfo->ungottenchar = 0;
+
SCM_PORT_SET_PORTINFO(obj, pinfo);
+ SCM_PORT_SET_PORTTYPE(obj, PORT_STRING);
+ SCM_PORT_SET_STR(obj, strdup(str));
+ SCM_PORT_SET_STR_CURRENTPOS(obj, SCM_PORT_STR(obj));
+ SCM_PORT_SET_UNGOTTENCHAR(obj, 0);
return obj;
}
Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/debug.c 2005-10-06 18:10:39 UTC (rev 1824)
@@ -181,8 +181,8 @@
if (FALSEP(port))
return;
- if (SCM_PORTINFO_PORTTYPE(port) == PORT_FILE) {
- f = SCM_PORTINFO_FILE(port);
+ if (SCM_PORT_PORTTYPE(port) == PORT_FILE) {
+ f = SCM_PORT_FILE(port);
print_ScmObj_internal(f, obj, AS_WRITE);
#if SCM_VOLATILE_OUTPUT
fflush(f);
@@ -200,8 +200,8 @@
if (FALSEP(port))
return;
- if (SCM_PORTINFO_PORTTYPE(port) == PORT_FILE) {
- f = SCM_PORTINFO_FILE(port);
+ if (SCM_PORT_PORTTYPE(port) == PORT_FILE) {
+ f = SCM_PORT_FILE(port);
print_ScmObj_internal(f, obj, AS_DISPLAY);
#if SCM_VOLATILE_OUTPUT
fflush(f);
@@ -443,10 +443,10 @@
fprintf(f, "port ");
/* file or string */
- if (SCM_PORTINFO_PORTTYPE(port) == PORT_FILE)
- fprintf(f, "file %s", SCM_PORTINFO_FILENAME(port));
- else if (SCM_PORTINFO_PORTTYPE(port) == PORT_STRING)
- fprintf(f, "string %s", SCM_PORTINFO_STR(port));
+ if (SCM_PORT_PORTTYPE(port) == PORT_FILE)
+ fprintf(f, "file %s", SCM_PORT_FILENAME(port));
+ else if (SCM_PORT_PORTTYPE(port) == PORT_STRING)
+ fprintf(f, "string %s", SCM_PORT_STR(port));
fprintf(f, ">");
}
Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/error.c 2005-10-06 18:10:39 UTC (rev 1824)
@@ -234,7 +234,7 @@
FILE *err;
if (!FALSEP(scm_current_error_port)) {
- err = SCM_PORTINFO_FILE(scm_current_error_port);
+ err = SCM_PORT_FILE(scm_current_error_port);
vfprintf(err, fmt, args);
#if SCM_VOLATILE_OUTPUT
fflush(err);
@@ -247,7 +247,7 @@
FILE *err;
if (!FALSEP(scm_current_error_port)) {
- err = SCM_PORTINFO_FILE(scm_current_error_port);
+ err = SCM_PORT_FILE(scm_current_error_port);
fputc('\n', err);
#if SCM_VOLATILE_OUTPUT
fflush(err);
Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/io.c 2005-10-06 18:10:39 UTC (rev 1824)
@@ -250,8 +250,8 @@
ASSERT_PORTP(port);
- if (SCM_PORTINFO_FILE(port))
- fclose(SCM_PORTINFO_FILE(port));
+ if (SCM_PORT_FILE(port))
+ fclose(SCM_PORT_FILE(port));
return SCM_UNDEF;
}
@@ -262,8 +262,8 @@
ASSERT_PORTP(port);
- if (SCM_PORTINFO_FILE(port))
- fclose(SCM_PORTINFO_FILE(port));
+ if (SCM_PORT_FILE(port))
+ fclose(SCM_PORT_FILE(port));
return SCM_UNDEF;
}
@@ -294,7 +294,7 @@
port = CAR(args);
/* TODO : implement this multibyte-char awareness */
- buf[0] = getc(SCM_PORTINFO_FILE(port));
+ buf[0] = getc(SCM_PORT_FILE(port));
buf[1] = '\0';
return Scm_NewChar(buf);
}
Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/read.c 2005-10-06 18:10:39 UTC (rev 1824)
@@ -68,29 +68,29 @@
/*=======================================
File Local Macro Declarations
=======================================*/
-#define SCM_PORT_GETC(port, c) \
- do { \
- if (SCM_PORTINFO_UNGOTTENCHAR(port)) { \
- c = SCM_PORTINFO_UNGOTTENCHAR(port); \
- SCM_PORTINFO_UNGOTTENCHAR(port) = 0; \
- } else { \
- switch (SCM_PORTINFO_PORTTYPE(port)) { \
- case PORT_FILE: \
- c = getc(SCM_PORTINFO_FILE(port)); \
- if (c == '\n') SCM_PORTINFO_LINE(port)++; \
- break; \
- case PORT_STRING: \
- c = (*SCM_PORTINFO_STR_CURRENT(port)); \
- if (c == '\0') c = EOF; \
- SCM_PORTINFO_STR_CURRENT(port)++; \
- break; \
- } \
- SCM_PORTINFO_UNGOTTENCHAR(port) = 0; \
- } \
+#define SCM_PORT_GETC(port, c) \
+ do { \
+ if (SCM_PORT_UNGOTTENCHAR(port)) { \
+ c = SCM_PORT_UNGOTTENCHAR(port); \
+ SCM_PORT_SET_UNGOTTENCHAR(port, 0); \
+ } else { \
+ switch (SCM_PORT_PORTTYPE(port)) { \
+ case PORT_FILE: \
+ c = getc(SCM_PORT_FILE(port)); \
+ if (c == '\n') SCM_PORT_LINE(port)++; \
+ break; \
+ case PORT_STRING: \
+ c = (*SCM_PORT_STR_CURRENTPOS(port)); \
+ if (c == '\0') c = EOF; \
+ SCM_PORT_STR_CURRENTPOS(port)++; \
+ break; \
+ } \
+ SCM_PORT_SET_UNGOTTENCHAR(port, 0); \
+ } \
} while (0);
-#define SCM_PORT_UNGETC(port,c) \
- SCM_PORTINFO_UNGOTTENCHAR(port) = c;
+#define SCM_PORT_UNGETC(port,c) \
+ SCM_PORT_SET_UNGOTTENCHAR(port, c);
/*=======================================
Variable Declarations
@@ -246,7 +246,7 @@
ScmObj list_tail = SCM_NULL;
ScmObj item = SCM_NULL;
ScmObj cdr = SCM_NULL;
- int line = SCM_PORTINFO_LINE(port);
+ int line = SCM_PORT_LINE(port);
int c = 0;
int c2 = 0;
char *token = NULL;
@@ -259,7 +259,7 @@
CDBG((SCM_DBG_PARSER, "read_list c = [%c]", c));
if (c == EOF) {
- if (SCM_PORTINFO_PORTTYPE(port) == PORT_FILE)
+ if (SCM_PORT_PORTTYPE(port) == PORT_FILE)
SigScm_Error("EOF inside list. (starting from line %d)", line + 1);
else
SigScm_Error("EOF inside list.");
Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h 2005-10-06 16:20:26 UTC (rev 1823)
+++ branches/r5rs/sigscheme/sigschemetype.h 2005-10-06 18:10:39 UTC (rev 1824)
@@ -113,7 +113,7 @@
struct {
char *port_str;
- const char *str_current;
+ const char *str_currentpos;
} str_port;
} info;
@@ -347,14 +347,24 @@
#define SCM_PORT_SET_PORTDIRECTION(a, pdirection) (SCM_PORT_PORTDIRECTION(a) = pdirection)
#define SCM_PORT_PORTINFO(a) (SCM_AS_PORT(a)->obj.port.port_info)
#define SCM_PORT_SET_PORTINFO(a, pinfo) (SCM_PORT_PORTINFO(a) = (pinfo))
-#define SCM_PORTINFO_PORTTYPE(a) (SCM_PORT_PORTINFO(a)->port_type)
-#define SCM_PORTINFO_FILE(a) (SCM_PORT_PORTINFO(a)->info.file_port.file)
-#define SCM_PORTINFO_FILENAME(a) (SCM_PORT_PORTINFO(a)->info.file_port.filename)
-#define SCM_PORTINFO_LINE(a) (SCM_PORT_PORTINFO(a)->info.file_port.line)
-#define SCM_PORTINFO_STR(a) (SCM_PORT_PORTINFO(a)->info.str_port.port_str)
-#define SCM_PORTINFO_STR_CURRENT(a) (SCM_PORT_PORTINFO(a)->info.str_port.str_current)
-#define SCM_PORTINFO_UNGOTTENCHAR(a) (SCM_PORT_PORTINFO(a)->ungottenchar)
+#define SCM_PORT_PORTTYPE(a) (SCM_PORT_PORTINFO(a)->port_type)
+#define SCM_PORT_SET_PORTTYPE(a, type) (SCM_PORT_PORTTYPE(a) = type)
+#define SCM_PORT_UNGOTTENCHAR(a) (SCM_PORT_PORTINFO(a)->ungottenchar)
+#define SCM_PORT_SET_UNGOTTENCHAR(a, ch) (SCM_PORT_UNGOTTENCHAR(a) = ch)
+/* File Port */
+#define SCM_PORT_FILE(a) (SCM_PORT_PORTINFO(a)->info.file_port.file)
+#define SCM_PORT_SET_FILE(a, file) (SCM_PORT_FILE(a) = file)
+#define SCM_PORT_FILENAME(a) (SCM_PORT_PORTINFO(a)->info.file_port.filename)
+#define SCM_PORT_SET_FILENAME(a, filename) (SCM_PORT_FILENAME(a) = filename)
+#define SCM_PORT_LINE(a) (SCM_PORT_PORTINFO(a)->info.file_port.line)
+#define SCM_PORT_SET_LINE(a, line) (SCM_PORT_LINE(a) = line)
+/* String Port */
+#define SCM_PORT_STR(a) (SCM_PORT_PORTINFO(a)->info.str_port.port_str)
+#define SCM_PORT_SET_STR(a, str) (SCM_PORT_STR(a) = str)
+#define SCM_PORT_STR_CURRENTPOS(a) (SCM_PORT_PORTINFO(a)->info.str_port.str_currentpos)
+#define SCM_PORT_SET_STR_CURRENTPOS(a, pos) (SCM_PORT_STR_CURRENTPOS(a) = pos)
+
#define SCM_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
#define SCM_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
#define SCM_CONTINUATION_OPAQUE0(a) (SCM_AS_CONTINUATION(a)->obj.continuation.opaque0)
More information about the uim-commit
mailing list