[uim-commit] r2104 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Nov 8 19:36:55 PST 2005
Author: yamaken
Date: 2005-11-08 19:36:52 -0800 (Tue, 08 Nov 2005)
New Revision: 2104
Modified:
branches/r5rs/sigscheme/debug.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/sigschemetype-compact.h
branches/r5rs/sigscheme/test-compact.c
Log:
* sigscheme/sigscheme.h
- (SCM_WORD_CAST): New macro
- (SCM_REINTERPRET_CAST): Resurrect previous definition before r2100
* sigscheme/test-compact.c
- (SCM_REINTERPRET_CAST): Removed the re-definition
* sigscheme/sigschemetype-compact.h
- (SCM_FUNC_CFUNC, SCM_FUNC_SET_CFUNC, SCM_C_FUNCPOINTER_VALUE,
SCM_C_FUNCPOINTER_SET_VALUE): Replace SCM_REINTERPRET_CAST() with
SCM_WORD_CAST()
* sigscheme/debug.c
- (print_ScmObj_internal): Ditto
Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c 2005-11-08 22:55:04 UTC (rev 2103)
+++ branches/r5rs/sigscheme/debug.c 2005-11-09 03:36:52 UTC (rev 2104)
@@ -284,7 +284,7 @@
break;
case ScmCFuncPointer:
SigScm_PortPrintf(port, "#<c_func_pointer %p>",
- SCM_REINTERPRET_CAST(void *, SCM_C_FUNCPOINTER_VALUE(obj)));
+ SCM_WORD_CAST(void *, SCM_C_FUNCPOINTER_VALUE(obj)));
break;
}
}
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-11-08 22:55:04 UTC (rev 2103)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-11-09 03:36:52 UTC (rev 2104)
@@ -63,7 +63,14 @@
#define SCM_NORETURN
#endif /* __GNUC__ */
-#define SCM_REINTERPRET_CAST(type, obj) ((type)(int)(obj))
+/* Casts a machine word mainly a function pointer and (void *) */
+#define SCM_WORD_CAST(type, obj) ((type)(unsigned long)(obj))
+/*
+ * Re-interprets a storage as-is, similarly to reinterpret_cast<type>(obj) of
+ * C++. Don't change the semantics. This cast requires that obj is a pointable
+ * storage.
+ */
+#define SCM_REINTERPRET_CAST(type, obj) (*(type *)&(obj))
/* RFC: better names for the debug printing */
#if SCM_DEBUG
Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-08 22:55:04 UTC (rev 2103)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h 2005-11-09 03:36:52 UTC (rev 2104)
@@ -462,9 +462,9 @@
#define SCM_VALUEPACKET_VALUES(a) (SCM_AS_VALUEPACKET(a)->car)
#define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_SET_VALUE_AS_OBJ(SCM_VALUEPACKET_VALUES(a), (v)))
-#define SCM_FUNC_CFUNC(a) (SCM_REINTERPRET_CAST(ScmFuncType, (SCM_AS_FUNC(a)->car)))
+#define SCM_FUNC_CFUNC(a) (SCM_WORD_CAST(ScmFuncType, (SCM_AS_FUNC(a)->car)))
#define SCM_FUNC_TYPECODE(a) ((enum ScmFuncTypeCode)SCM_GET_VALUE_AS_INT(SCM_AS_FUNC(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_FUNC))
-#define SCM_FUNC_SET_CFUNC(a, fptr) (SCM_AS_FUNC(a)->car = SCM_REINTERPRET_CAST(ScmObj, (fptr)))
+#define SCM_FUNC_SET_CFUNC(a, fptr) (SCM_AS_FUNC(a)->car = SCM_WORD_CAST(ScmObj, (fptr)))
#define SCM_FUNC_SET_TYPECODE(a, code) (SCM_SET_VALUE_AS_INT(SCM_AS_FUNC(a)->cdr, (code), SCM_TAG_OTHERS_VALUE_OFFSET_FUNC, SCM_TAG_OTHERS_FUNC))
#define SCM_SYNTAXP(a) (SCM_FUNCP(a) \
&& (SCM_FUNC_TYPECODE(a) & SCM_FUNCTYPE_SYNTAX))
@@ -488,8 +488,8 @@
#define SCM_C_POINTER_VALUE(a) ((void*)SCM_AS_C_POINTER(a)->car)
#define SCM_C_POINTER_SET_VALUE(a, val) (SCM_AS_C_POINTER(a)->car = (ScmObj)(val))
-#define SCM_C_FUNCPOINTER_VALUE(a) (SCM_REINTERPRET_CAST(ScmCFunc, SCM_AS_C_FUNCPOINTER(a)->car))
-#define SCM_C_FUNCPOINTER_SET_VALUE(a, val) (SCM_AS_C_FUNCPOINTER(a)->car = SCM_REINTERPRET_CAST(ScmObj, (val)))
+#define SCM_C_FUNCPOINTER_VALUE(a) (SCM_WORD_CAST(ScmCFunc, SCM_AS_C_FUNCPOINTER(a)->car))
+#define SCM_C_FUNCPOINTER_SET_VALUE(a, val) (SCM_AS_C_FUNCPOINTER(a)->car = SCM_WORD_CAST(ScmObj, (val)))
#define SCM_INT_VALUE(a) (SCM_GET_VALUE_AS_INT((a), SCM_TAG_IMM_VALUE_OFFSET_INT))
#define SCM_INT_SET_VALUE(a, val) (SCM_SET_VALUE_AS_INT((a), (val), SCM_TAG_IMM_VALUE_OFFSET_INT, SCM_TAG_IMM_INT))
Modified: branches/r5rs/sigscheme/test-compact.c
===================================================================
--- branches/r5rs/sigscheme/test-compact.c 2005-11-08 22:55:04 UTC (rev 2103)
+++ branches/r5rs/sigscheme/test-compact.c 2005-11-09 03:36:52 UTC (rev 2104)
@@ -35,8 +35,6 @@
#include <stdio.h>
#include <stdlib.h>
-#define SCM_REINTERPRET_CAST(type, obj) ((type)(int)(obj))
-
#include "sigschemetype-compact.h"
typedef void (*ScmCFunc)(void);
More information about the uim-commit
mailing list