[uim-commit] r1668 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Wed Sep 28 08:24:36 PDT 2005
Author: kzk
Date: 2005-09-28 08:24:34 -0700 (Wed, 28 Sep 2005)
New Revision: 1668
Modified:
branches/r5rs/sigscheme/io.c
branches/r5rs/sigscheme/sigscheme.c
branches/r5rs/sigscheme/sigscheme.h
Log:
* simplify "read", "read-char", "write", "display", "newline"
and "write-char" with new FUNCTYPE scheme
* sigscheme/io.c
* sigscheme/sigscheme.h
- (ScmOp_read,
ScmOp_read_char,
ScmOp_write,
ScmOp_display,
ScmOp_newline,
ScmOp_write_char): change args
* sigscheme/sigscheme.c
- (SigScm_Initialize_internal)
- "read": export by Scm_RegisterProcedureVariadic0
- "read-char": export by Scm_RegisterProcedureVariadic0
- "write": export by Scm_RegisterProcedureVariadic1
- "display": export by Scm_RegisterProcedureVariadic1
- "newline": export by Scm_RegisterProcedureVariadic0
- "write-char": export by Scm_RegisterProcedureVariadic1
Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c 2005-09-28 15:17:56 UTC (rev 1667)
+++ branches/r5rs/sigscheme/io.c 2005-09-28 15:24:34 UTC (rev 1668)
@@ -268,36 +268,26 @@
/*===========================================================================
R5RS : 6.6 Input and Output : 6.6.2 Input
===========================================================================*/
-ScmObj ScmOp_read(ScmObj arg, ScmObj env)
+ScmObj ScmOp_read(ScmObj args)
{
- ScmObj port = SCM_NULL;
- if (NULLP(arg)) {
- /* (read) */
- port = scm_current_input_port;
- } else if (PORTP(CAR(arg))) {
- /* (read port) */
- port = CAR(arg);
- } else {
- SigScm_ErrorObj("read : invalid parameter", arg);
- }
+ ScmObj port = scm_current_input_port;
+ /* get port */
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
+
return SigScm_Read(port);
}
-ScmObj ScmOp_read_char(ScmObj arg, ScmObj env)
+ScmObj ScmOp_read_char(ScmObj args)
{
- ScmObj port = SCM_NULL;
+ ScmObj port = scm_current_input_port;
char *buf = NULL;
- if (NULLP(arg)) {
- /* (read-char) */
- port = scm_current_input_port;
- } else if (!NULLP(CDR(arg)) && PORTP(CADR(arg))) {
- /* (read-char port) */
- port = CADR(arg);
- } else {
- SigScm_ErrorObj("read-char : invalid parameter", arg);
- }
+ /* get port */
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
+
/* TODO : implement this multibyte-char awareness */
buf = (char *)malloc(sizeof(char) * 2);
buf[0] = getc(SCM_PORTINFO_FILE(port));
@@ -323,84 +313,54 @@
/*===========================================================================
R5RS : 6.6 Input and Output : 6.6.3 Output
===========================================================================*/
-ScmObj ScmOp_write(ScmObj arg, ScmObj env)
+ScmObj ScmOp_write(ScmObj obj, ScmObj args)
{
- ScmObj obj = SCM_NULL;
- ScmObj port = SCM_NULL;
+ ScmObj port = scm_current_output_port;
- if CHECK_1_ARG(arg)
- SigScm_Error("write : invalid parameter");
-
- /* get obj */
- obj = CAR(arg);
- arg = CDR(arg);
-
/* get port */
- port = scm_current_output_port;
- if (!NULLP(arg) && !NULLP(CAR(arg)) && PORTP(CAR(arg)))
- port = CAR(arg);
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
SigScm_WriteToPort(port, obj);
return SCM_UNDEF;
}
-ScmObj ScmOp_display(ScmObj arg, ScmObj env)
+ScmObj ScmOp_display(ScmObj obj, ScmObj args)
{
- ScmObj obj = SCM_NULL;
- ScmObj port = SCM_NULL;
-
- if CHECK_1_ARG(arg)
- SigScm_Error("display : invalid parameter");
-
- /* get obj */
- obj = CAR(arg);
- arg = CDR(arg);
-
- /* get port */
- port = scm_current_output_port;
+ ScmObj port = scm_current_output_port;
- /* (display obj port) */
- if (!NULLP(arg) && PORTP(CAR(arg)))
- port = CAR(arg);
+ /* get port */
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
SigScm_DisplayToPort(port, obj);
return SCM_UNDEF;
}
-ScmObj ScmOp_newline(ScmObj arg, ScmObj env)
+ScmObj ScmOp_newline(ScmObj args)
{
/* get port */
ScmObj port = scm_current_output_port;
/* (newline port) */
- if (!NULLP(arg) && !NULLP(CAR(arg)) && PORTP(CAR(arg))) {
- port = CAR(arg);
- }
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
SigScm_DisplayToPort(port, Scm_NewStringCopying("\n"));
return SCM_UNDEF;
}
-ScmObj ScmOp_write_char(ScmObj arg, ScmObj env)
+ScmObj ScmOp_write_char(ScmObj obj, ScmObj args)
{
- ScmObj obj = SCM_NULL;
- ScmObj port = SCM_NULL;
+ ScmObj port = scm_current_output_port;
- if CHECK_1_ARG(arg)
- SigScm_Error("write-char : invalid parameter");
-
- /* get obj */
- obj = CAR(arg);
- arg = CDR(arg);
+ /* sanity check */
if (!CHARP(obj))
SigScm_ErrorObj("write-char : char required but got ", obj);
/* get port */
- port = scm_current_output_port;
-
- /* (write-char obj port) */
- if (!NULLP(arg) && PORTP(CAR(arg)))
- port = CAR(arg);
+ if (!NULLP(args) && PORTP(CAR(args)))
+ port = CAR(args);
SigScm_DisplayToPort(port, obj);
return SCM_UNDEF;
Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c 2005-09-28 15:17:56 UTC (rev 1667)
+++ branches/r5rs/sigscheme/sigscheme.c 2005-09-28 15:24:34 UTC (rev 1668)
@@ -311,12 +311,12 @@
Scm_RegisterFunc1("close-input-port" , ScmOp_close_input_port);
Scm_RegisterFunc1("close-output-port" , ScmOp_close_output_port);
Scm_RegisterFunc1("eof-object?" , ScmOp_eof_objectp);
- Scm_RegisterFuncEvaledList("read" , ScmOp_read);
- Scm_RegisterFuncEvaledList("read-char" , ScmOp_read_char);
- Scm_RegisterFuncEvaledList("write" , ScmOp_write);
- Scm_RegisterFuncEvaledList("display" , ScmOp_display);
- Scm_RegisterFuncEvaledList("newline" , ScmOp_newline);
- Scm_RegisterFuncEvaledList("write-char" , ScmOp_write_char);
+ Scm_RegisterProcedureVariadic0("read" , ScmOp_read);
+ Scm_RegisterProcedureVariadic0("read-char" , ScmOp_read_char);
+ Scm_RegisterProcedureVariadic1("write" , ScmOp_write);
+ Scm_RegisterProcedureVariadic1("display" , ScmOp_display);
+ Scm_RegisterProcedureVariadic0("newline" , ScmOp_newline);
+ Scm_RegisterProcedureVariadic1("write-char" , ScmOp_write_char);
Scm_RegisterFunc1("load" , ScmOp_load);
#if SCM_USE_NONSTD_FEATURES
Scm_RegisterFunc1("require" , ScmOp_require);
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-09-28 15:17:56 UTC (rev 1667)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-09-28 15:24:34 UTC (rev 1668)
@@ -538,15 +538,15 @@
ScmObj ScmOp_close_input_port(ScmObj port);
ScmObj ScmOp_close_output_port(ScmObj port);
-ScmObj ScmOp_read(ScmObj arg, ScmObj env);
-ScmObj ScmOp_read_char(ScmObj arg, ScmObj env);
+ScmObj ScmOp_read(ScmObj args);
+ScmObj ScmOp_read_char(ScmObj args);
ScmObj ScmOp_peek_char(ScmObj arg, ScmObj env);
ScmObj ScmOp_eof_objectp(ScmObj obj);
ScmObj ScmOp_char_readyp(ScmObj arg, ScmObj env);
-ScmObj ScmOp_write(ScmObj arg, ScmObj env);
-ScmObj ScmOp_display(ScmObj arg, ScmObj env);
-ScmObj ScmOp_newline(ScmObj arg, ScmObj env);
-ScmObj ScmOp_write_char(ScmObj arg, ScmObj env);
+ScmObj ScmOp_write(ScmObj obj, ScmObj args);
+ScmObj ScmOp_display(ScmObj obj, ScmObj args);
+ScmObj ScmOp_newline(ScmObj args);
+ScmObj ScmOp_write_char(ScmObj obj, ScmObj args);
ScmObj SigScm_load(const char *c_filename);
ScmObj ScmOp_load(ScmObj filename);
More information about the uim-commit
mailing list