[uim-commit] r1917 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Mon Oct 31 22:02:19 PST 2005


Author: yamaken
Date: 2005-10-31 22:02:15 -0800 (Mon, 31 Oct 2005)
New Revision: 1917

Modified:
   branches/r5rs/sigscheme/fileport.c
   branches/r5rs/sigscheme/mbcport.c
   branches/r5rs/sigscheme/mbcport.h
   branches/r5rs/sigscheme/sbcport.c
   branches/r5rs/sigscheme/sbcport.h
   branches/r5rs/sigscheme/strport.c
Log:
* sigscheme/sbcport.h
  - (ScmSingleByteCharPort): Moved from sbcport.c
  - (ScmBaseCharPort_construct, ScmSingleByteCharPort_construct): New
    function
* sigscheme/sbcport.c
  - (ScmSingleByteCharPort): Move to sbcport.h
  - (ScmBaseCharPort_construct, ScmSingleByteCharPort_construct): New
    function
  - (ScmSingleByteCharPort_new): Simplify
* sigscheme/mbcport.h
  - (ScmMultiByteCharPort): Moved from mbcport.c
  - (ScmMultiByteCharPort_construct): New function decl
* sigscheme/mbcport.c
  - (ScmMultiByteCharPort): Move to mbcport.h
  - (ScmMultiByteCharPort_construct): New function
  - (ScmMultiByteCharPort_new): Simplify
* sigscheme/fileport.c
  - (ScmFilePort_new): Simplify with SCM_PORT_ALLOC()
* sigscheme/strport.c
  - (istrport_new, ScmOutputStrPort_new): Ditto


Modified: branches/r5rs/sigscheme/fileport.c
===================================================================
--- branches/r5rs/sigscheme/fileport.c	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/fileport.c	2005-11-01 06:02:15 UTC (rev 1917)
@@ -117,9 +117,7 @@
 {
     ScmFilePort *port;
 
-    port = malloc(sizeof(ScmFilePort));
-    if (!port)
-        SCM_PORT_ERROR_NOMEM(BYTE, NULL, ScmFilePort);
+    SCM_PORT_ALLOC(BYTE, port, ScmFilePort);
 
     port->vptr = ScmFilePort_vptr;
     port->file = file;

Modified: branches/r5rs/sigscheme/mbcport.c
===================================================================
--- branches/r5rs/sigscheme/mbcport.c	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/mbcport.c	2005-11-01 06:02:15 UTC (rev 1917)
@@ -67,8 +67,6 @@
 /*=======================================
   File Local Type Definitions
 =======================================*/
-typedef struct ScmMultiByteCharPort_ ScmMultiByteCharPort;
-
 struct ScmMultiByteCharPort_ {  /* inherits ScmBaseCharPort */
     const ScmCharPortVTbl *vptr;
 
@@ -121,21 +119,27 @@
     vptr->put_char    = (ScmCharPortMethod_put_char)&mbcport_put_char;
 }
 
+void
+ScmMultiByteCharPort_construct(ScmMultiByteCharPort *port,
+                               const ScmCharPortVTbl *vptr,
+                               ScmBytePort *bport, ScmCharCodec *codec)
+{
+    ScmBaseCharPort_construct((ScmBaseCharPort *)port, vptr, bport);
+
+    cport->codec = codec;
+    cport->rbuf[0] = '\0';
+    SCM_MBCPORT_CLEAR_STATE(cport);
+}
+
 ScmCharPort *
 ScmMultiByteCharPort_new(ScmBytePort *bport, ScmCharCodec *codec)
 {
     ScmMultiByteCharPort *cport;
 
-    cport = malloc(sizeof(ScmMultiByteCharPort));
-    if (!cport)
-        SCM_PORT_ERROR_NOMEM(CHAR, cport, ScmMultiByteCharPort);
+    SCM_PORT_ALLOC(CHAR, cport, ScmMultiByteCharPort);
+    ScmMultiByteCharPort_construct(cport, ScmMultiByteCharPort_vptr,
+                                   bport, codec);
 
-    cport->vptr = ScmMultiByteCharPort_vptr;
-    cport->bport = bport;
-    cport->codec = codec;
-    cport->rbuf[0] = '\0';
-    SCM_MBCPORT_CLEAR_STATE(cport);
-
     return (ScmCharPort *)cport;
 }
 

Modified: branches/r5rs/sigscheme/mbcport.h
===================================================================
--- branches/r5rs/sigscheme/mbcport.h	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/mbcport.h	2005-11-01 06:02:15 UTC (rev 1917)
@@ -61,6 +61,7 @@
 /*=======================================
   Type Definitions
 =======================================*/
+typedef struct ScmMultiByteCharPort_ ScmMultiByteCharPort;
 
 /*=======================================
    Variable Declarations
@@ -71,6 +72,10 @@
    Function Declarations
 =======================================*/
 void Scm_mbcport_init(void);
+
+void ScmMultiByteCharPort_construct(ScmMultiByteCharPort *port,
+                                    const ScmCharPortVTbl *vptr,
+                                    ScmBytePort *bport, ScmCharCodec *codec);
 ScmCharPort *ScmMultiByteCharPort_new(ScmBytePort *bport, ScmCharCodec *codec);
 
 

Modified: branches/r5rs/sigscheme/sbcport.c
===================================================================
--- branches/r5rs/sigscheme/sbcport.c	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/sbcport.c	2005-11-01 06:02:15 UTC (rev 1917)
@@ -57,8 +57,6 @@
 /*=======================================
   File Local Type Definitions
 =======================================*/
-typedef struct ScmSingleByteCharPort_ ScmSingleByteCharPort;
-
 struct ScmSingleByteCharPort_ {  /* inherits ScmBaseCharPort */
     const ScmCharPortVTbl *vptr;
 
@@ -109,6 +107,14 @@
 /*=======================================
   Function Implementations
 =======================================*/
+void
+ScmBaseCharPort_construct(ScmBaseCharPort *port, const ScmCharPortVTbl *vptr,
+                          ScmBytePort *bport)
+{
+    port->vptr = ScmSingleByteCharPort_vptr;
+    port->bport = bport;
+}
+
 static ScmCharPort *
 basecport_dyn_cast(ScmCharPort *cport, const ScmCharPortVTbl *dst_vptr)
 {
@@ -184,18 +190,22 @@
     ScmSingleByteCharPort_vtbl.put_char = (ScmCharPortMethod_put_char)&sbcport_put_char;
 }
 
+void
+ScmSingleByteCharPort_construct(ScmSingleByteCharPort *port,
+                                const ScmCharPortVTbl *vptr,
+                                ScmBytePort *bport)
+{
+    ScmBaseCharPort_construct((ScmBaseCharPort *)port, vptr, bport);
+}
+
 ScmCharPort *
 ScmSingleByteCharPort_new(ScmBytePort *bport)
 {
     ScmSingleByteCharPort *cport;
 
-    cport = malloc(sizeof(ScmSingleByteCharPort));
-    if (!cport)
-        SCM_PORT_ERROR_NOMEM(CHAR, cport, ScmSingleByteCharPort);
+    SCM_PORT_ALLOC(CHAR, cport, ScmSingleByteCharPort);
+    ScmSingleByteCharPort_construct(cport, ScmSingleByteCharPort_vptr, bport);
 
-    cport->vptr = ScmSingleByteCharPort_vptr;
-    cport->bport = bport;
-
     return (ScmCharPort *)cport;
 }
 

Modified: branches/r5rs/sigscheme/sbcport.h
===================================================================
--- branches/r5rs/sigscheme/sbcport.h	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/sbcport.h	2005-11-01 06:02:15 UTC (rev 1917)
@@ -57,6 +57,7 @@
   Type Definitions
 =======================================*/
 typedef struct ScmBaseCharPort_ ScmBaseCharPort;
+typedef struct ScmSingleByteCharPort_ ScmSingleByteCharPort;
 
 struct ScmBaseCharPort_ {  /* inherits ScmCharPort */
     const ScmCharPortVTbl *vptr;
@@ -74,6 +75,14 @@
    Function Declarations
 =======================================*/
 void Scm_sbcport_init(void);
+
+void ScmBaseCharPort_construct(ScmBaseCharPort *port,
+                               const ScmCharPortVTbl *vptr,
+                               ScmBytePort *bport);
+
+void ScmSingleByteCharPort_construct(ScmSingleByteCharPort *port,
+                                     const ScmCharPortVTbl *vptr,
+                                     ScmBytePort *bport);
 ScmCharPort *ScmSingleByteCharPort_new(ScmBytePort *bport);
 
 

Modified: branches/r5rs/sigscheme/strport.c
===================================================================
--- branches/r5rs/sigscheme/strport.c	2005-11-01 05:55:09 UTC (rev 1916)
+++ branches/r5rs/sigscheme/strport.c	2005-11-01 06:02:15 UTC (rev 1917)
@@ -167,9 +167,7 @@
 {
     ScmInputStrPort *port;
 
-    port = malloc(sizeof(ScmInputStrPort));
-    if (!port)
-        SCM_PORT_ERROR_NOMEM(BYTE, NULL, ScmInputStrPort);
+    SCM_PORT_ALLOC(BYTE, port, ScmInputStrPort);
 
     port->vptr = ScmInputStrPort_vptr;
     port->cur = port->str = str;
@@ -285,9 +283,7 @@
 {
     ScmOutputStrPort *port;
 
-    port = malloc(sizeof(ScmOutputStrPort));
-    if (!port)
-        SCM_PORT_ERROR_NOMEM(BYTE, NULL, ScmOutputStrPort);
+    SCM_PORT_ALLOC(BYTE, port, ScmOutputStrPort);
 
     port->vptr = ScmOutputStrPort_vptr;
     port->str = NULL;



More information about the uim-commit mailing list