[uim-commit] r1879 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Mon Oct 24 00:15:45 PDT 2005
Author: yamaken
Date: 2005-10-24 00:15:36 -0700 (Mon, 24 Oct 2005)
New Revision: 1879
Modified:
branches/r5rs/sigscheme/baseport.h
branches/r5rs/sigscheme/fileport.c
branches/r5rs/sigscheme/sbcport.c
Log:
* sigscheme/baseport.h
- (SCM_PORT_DYNAMIC_CAST): Add a comment
* sigscheme/fileport.c
- (fileport_close, fileport_get_byte, fileport_peek_byte,
fileport_vprintf, fileport_puts, fileport_write, fileport_flush):
Replace unnecessary SCM_PORT_DYNAMIC_CAST() with normal cast
* sigscheme/sbcport.c
- (basecport_close, basecport_get_char, basecport_peek_char,
basecport_char_readyp, basecport_vprintf, basecport_flush,
sbcport_encoding, sbcport_put_char): Ditto
Modified: branches/r5rs/sigscheme/baseport.h
===================================================================
--- branches/r5rs/sigscheme/baseport.h 2005-10-24 06:58:16 UTC (rev 1878)
+++ branches/r5rs/sigscheme/baseport.h 2005-10-24 07:15:36 UTC (rev 1879)
@@ -61,6 +61,10 @@
#define SCM_BYTEPORT_ERROR(bport, msg) (exit(EXIT_FAILURE))
#endif /* SCM_BYTEPORT_ERROR */
+/*
+ * To allow safe method invocation (contains from subclasses), all non-standard
+ * method must call SCM_PORT_DYNAMIC_CAST() explicitly.
+ */
#define SCM_PORT_DYNAMIC_CAST(type, obj) \
((type *)(*obj->vptr->dyn_cast)(obj, &type##_vtbl))
Modified: branches/r5rs/sigscheme/fileport.c
===================================================================
--- branches/r5rs/sigscheme/fileport.c 2005-10-24 06:58:16 UTC (rev 1878)
+++ branches/r5rs/sigscheme/fileport.c 2005-10-24 07:15:36 UTC (rev 1879)
@@ -116,10 +116,6 @@
return (ScmBytePort *)port;
}
-/*
- * To allow method invocation from subclasses, all method must call
- * SCM_PORT_DYNAMIC_CAST() explicitly.
- */
static ScmBytePort *
fileport_dyn_cast(ScmBytePort *bport, const ScmBytePortVTbl *dst_vptr)
{
@@ -138,7 +134,7 @@
ScmFilePort *fport;
int err;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
err = fclose(fport->file);
free(fport);
@@ -150,7 +146,7 @@
{
ScmFilePort *fport;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
return getc(fport->file);
}
@@ -160,7 +156,7 @@
ScmFilePort *fport;
int ch;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
ch = getc(fport->file);
return ungetc(ch, fport->file);
}
@@ -178,7 +174,7 @@
{
ScmFilePort *fport;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
return vfprintf(fport->file, str, args);
}
@@ -187,7 +183,7 @@
{
ScmFilePort *fport;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
return fputs(str, fport->file);
}
@@ -196,7 +192,7 @@
{
ScmFilePort *fport;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
return fwrite(buf, 1, nbytes, fport->file);
}
@@ -205,6 +201,6 @@
{
ScmFilePort *fport;
- fport = SCM_PORT_DYNAMIC_CAST(ScmFilePort, bport);
+ fport = (ScmFilePort *)bport;
return fflush(fport->file);
}
Modified: branches/r5rs/sigscheme/sbcport.c
===================================================================
--- branches/r5rs/sigscheme/sbcport.c 2005-10-24 06:58:16 UTC (rev 1878)
+++ branches/r5rs/sigscheme/sbcport.c 2005-10-24 07:15:36 UTC (rev 1879)
@@ -122,7 +122,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_CLOSE(basecport->bport);
}
@@ -131,7 +131,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_GET_BYTE(basecport->bport);
}
@@ -140,7 +140,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_PEEK_BYTE(basecport->bport);
}
@@ -149,7 +149,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_BYTE_READYP(basecport->bport);
}
@@ -158,7 +158,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_VPRINTF(basecport->bport, str, args);
}
@@ -167,7 +167,7 @@
{
ScmBaseCharPort *basecport;
- basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, cport);
+ basecport = (ScmBaseCharPort *)cport;
return SCM_BYTEPORT_FLUSH(basecport->bport);
}
@@ -213,7 +213,7 @@
{
ScmSingleByteCharPort *sbcport;
- sbcport = SCM_PORT_DYNAMIC_CAST(ScmSingleByteCharPort, cport);
+ sbcport = (ScmSingleByteCharPort *)cport;
return "US-ASCII";
}
@@ -224,6 +224,6 @@
char buf[1];
buf[0] = ch;
- sbcport = SCM_PORT_DYNAMIC_CAST(ScmSingleByteCharPort, cport);
+ sbcport = (ScmSingleByteCharPort *)cport;
return SCM_BYTEPORT_WRITE(sbcport->bport, 1, buf);
}
More information about the uim-commit
mailing list