[uim-commit] r1914 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Mon Oct 31 21:28:28 PST 2005
Author: yamaken
Date: 2005-10-31 21:28:25 -0800 (Mon, 31 Oct 2005)
New Revision: 1914
Modified:
branches/r5rs/sigscheme/baseport.h
Log:
* sigscheme/baseport.h
- (SCM_PORT_CREATOR_BODY, SCM_BYTEPORT_CREATOR_BODY,
SCM_CHARPORT_CREATOR_BODY): New macro
Modified: branches/r5rs/sigscheme/baseport.h
===================================================================
--- branches/r5rs/sigscheme/baseport.h 2005-11-01 04:48:02 UTC (rev 1913)
+++ branches/r5rs/sigscheme/baseport.h 2005-11-01 05:28:25 UTC (rev 1914)
@@ -72,6 +72,25 @@
#define SCM_PORT_ERROR_NOMEM(klass, port, type) \
SCM_##klass##PORT_ERROR(port, #type ": Out of memory")
+#define SCM_PORT_CREATOR_BODY(macro_klass, abstract_type, concrete_type, bport) \
+ do { \
+ concrete_type *port; \
+ \
+ port = malloc(sizeof(concrete_type)); \
+ if (!port) \
+ SCM_PORT_ERROR_NOMEM(macro_klass, port, concrete_type); \
+ \
+ concrete_type##_construct(port, concrete_type##_vptr, bport); \
+ \
+ return (abstract_type *)port; \
+ } while (/* CONSTCOND */ 0)
+
+#define SCM_BYTEPORT_CREATOR_BODY(concrete_type, bport) \
+ SCM_PORT_CREATOR_BODY(BYTE, ScmBytePort, concrete_type, bport)
+
+#define SCM_CHARPORT_CREATOR_BODY(concrete_type, bport) \
+ SCM_PORT_CREATOR_BODY(CHAR, ScmCharPort, concrete_type, bport)
+
/*
* To allow safe method invocation (contains from subclasses), all non-standard
* method must call SCM_PORT_DYNAMIC_CAST() explicitly.
More information about the uim-commit
mailing list