[uim-commit] r1351 - in branches/r5rs/sigscheme: . test

kzk at freedesktop.org kzk at freedesktop.org
Mon Aug 29 02:17:23 PDT 2005


Author: kzk
Date: 2005-08-29 02:17:18 -0700 (Mon, 29 Aug 2005)
New Revision: 1351

Modified:
   branches/r5rs/sigscheme/sigscheme.h
   branches/r5rs/sigscheme/sigschemetype.h
   branches/r5rs/sigscheme/test/test-num.scm
Log:
* disable accessor assert in default

* sigscheme/sigscheme.h
  - (SCM_ACCESSOR_ASSERT): new macro
* sigscheme/sigschemetype.h
  - disable accessor assert if SCM_ACCESSOR_ASSERT is 0

* sigscheme/test/test-num.scm
  - forgot to commit. add testcase for max, min



Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h	2005-08-29 08:53:13 UTC (rev 1350)
+++ branches/r5rs/sigscheme/sigscheme.h	2005-08-29 09:17:18 UTC (rev 1351)
@@ -73,6 +73,7 @@
 #define SCM_COMPAT_SIOD_BUGS    1  /* emulate the buggy behaviors of SIOD */
 #define SCM_STRICT_R5RS         0  /* use strict R5RS check */
 #define SCM_STRICT_ARGCHECK     0  /* enable strict argument check */
+#define SCM_ACCESSOR_ASSERT     0  /* enable strict type check with accessor */
 
 int SigScm_Die(const char *msg, const char *filename, int line); /* error.c */
 #define sigassert(cond) \

Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h	2005-08-29 08:53:13 UTC (rev 1350)
+++ branches/r5rs/sigscheme/sigschemetype.h	2005-08-29 09:17:18 UTC (rev 1351)
@@ -279,18 +279,49 @@
 /*=======================================
    Accessors For Scheme Objects
 =======================================*/
-#define SCM_TYPE(a)       ((a)->type)
+/* ScmObj Global Attribute */
+#define SCM_TYPE(a) ((a)->type)
 #define SCM_ENTYPE(a, objtype) ((a)->type = (objtype))
 #define SCM_MARK(a) ((a)->gcmark)
 
+/* Type Confirmation */
+#if SCM_ACCESSOR_ASSERT
+#define SCM_AS_INT(a)   (sigassert(SCM_INTP(a)), (a))
+#define SCM_AS_CONS(a)  (sigassert(SCM_CONSP(a)), (a))
+#define SCM_AS_SYMBOL(a)       (sigassert(SCM_SYMBOLP(a)), (a))
+#define SCM_AS_CHAR(a)  (sigassert(SCM_CHARP(a)), (a))
+#define SCM_AS_STRING(a)  (sigassert(SCM_STRINGP(a)), (a))
+#define SCM_AS_FUNC(a) (sigassert(SCM_FUNCP(a)), (a))
+#define SCM_AS_CLOSURE(a)  (sigassert(SCM_CLOSUREP(a)), (a))
+#define SCM_AS_VECTOR(a)  (sigassert(SCM_VECTORP(a)), (a))
+#define SCM_AS_PORT(a)  (sigassert(SCM_PORTP(a)), (a))
+#define SCM_AS_CONTINUATION(a)  (sigassert(SCM_CONTINUATIONP(a)), (a))
+#define SCM_AS_VALUEPACKET(a)           (sigassert(SCM_VALUEPACKETP(a)), (a))
+#define SCM_AS_C_POINTER(a)  (sigassert(SCM_C_POINTERP(a)), (a))
+#define SCM_AS_C_FUNCPOINTER(a)  (sigassert(SCM_C_FUNCPOINTERP(a)), (a))
+#else
+#define SCM_AS_INT(a) (a)
+#define SCM_AS_CONS(a) (a) 
+#define SCM_AS_SYMBOL(a) (a)
+#define SCM_AS_CHAR(a) (a)
+#define SCM_AS_STRING(a) (a)
+#define SCM_AS_FUNC(a) (a)
+#define SCM_AS_CLOSURE(a) (a)
+#define SCM_AS_VECTOR(a) (a)
+#define SCM_AS_PORT(a) (a)
+#define SCM_AS_CONTINUATION(a) (a)
+#define SCM_AS_VALUEPACKET(a) (a)
+#define SCM_AS_C_POINTER(a) (a)
+#define SCM_AS_C_FUNCPOINTER(a) (a)
+#endif /* SCM_ACCESSOR_ASSERT */
+
+/* Real Accessors */
 #define SCM_INTP(a)  (SCM_TYPE(a) == ScmInt)
-#define SCM_AS_INT(a)   (sigassert(SCM_INTP(a)), (a))
 #define SCM_ENTYPE_INT(a)    (SCM_ENTYPE((a), ScmInt))
 #define SCM_INT_VALUE(a) (SCM_AS_INT(a)->obj.int_value.value)
 #define SCM_INT_SET_VALUE(a, val) (SCM_INT_VALUE(a) = (val))
 
 #define SCM_CONSP(a) (SCM_TYPE(a) == ScmCons)
-#define SCM_AS_CONS(a)  (sigassert(SCM_CONSP(a)), (a))
 #define SCM_ENTYPE_CONS(a) (SCM_ENTYPE((a), ScmCons))
 #define SCM_CAR(a)   (SCM_AS_CONS(a)->obj.cons.car)
 #define SCM_CONS_SET_CAR(a,car)   (SCM_CAR(a) = car)
@@ -302,7 +333,6 @@
 #define SCM_CDDR(a)  (SCM_CDR(SCM_CDR(a)))
 
 #define SCM_SYMBOLP(a)      (SCM_TYPE(a) == ScmSymbol)
-#define SCM_AS_SYMBOL(a)       (sigassert(SCM_SYMBOLP(a)), (a))
 #define SCM_ENTYPE_SYMBOL(a)    (SCM_ENTYPE((a), ScmSymbol))
 #define SCM_SYMBOL_NAME(a)  (SCM_AS_SYMBOL(a)->obj.symbol.sym_name)
 #define SCM_SYMBOL_SET_NAME(a, name)   (SCM_SYMBOL_NAME(a) = (name))
@@ -310,13 +340,11 @@
 #define SCM_SYMBOL_SET_VCELL(a, vcell) (SCM_SYMBOL_VCELL(a) = (vcell))
 
 #define SCM_CHARP(a) (SCM_TYPE(a) == ScmChar)
-#define SCM_AS_CHAR(a)  (sigassert(SCM_CHARP(a)), (a))
 #define SCM_ENTYPE_CHAR(a) (SCM_ENTYPE((a), ScmChar))
 #define SCM_CHAR_VALUE(a) (SCM_AS_CHAR(a)->obj.ch.ch)
 #define SCM_CHAR_SET_VALUE(a, chr) (SCM_CHAR_VALUE(a) = (chr))
 
 #define SCM_STRINGP(a) (SCM_TYPE(a) == ScmString)
-#define SCM_AS_STRING(a)  (sigassert(SCM_STRINGP(a)), (a))
 #define SCM_ENTYPE_STRING(a)  (SCM_ENTYPE((a), ScmString))
 #define SCM_STRING_STR(a) (SCM_AS_STRING(a)->obj.string.str)
 #define SCM_STRING_SET_STR(a, str) (SCM_STRING_STR(a) = (str))
@@ -324,7 +352,6 @@
 #define SCM_STRING_SET_LEN(a, len) (SCM_STRING_LEN(a) = (len))
 
 #define SCM_FUNCP(a) (SCM_TYPE(a) == ScmFunc)
-#define SCM_AS_FUNC(a) (sigassert(SCM_FUNCP(a)), (a))
 #define SCM_ENTYPE_FUNC(a)     (SCM_ENTYPE((a), ScmFunc))
 #define SCM_FUNC_TYPECODE(a) (SCM_AS_FUNC(a)->obj.func.type)
 #define SCM_FUNC_SET_TYPECODE(a, type) (SCM_FUNC_TYPECODE(a) = (type))
@@ -342,7 +369,6 @@
 #define SCM_FUNC_EXEC_SUBRF(a, arg1, arg2, arg3)             ((*(a)->obj.func.subrs.subrf.func) ((arg1), (arg2), (arg3)))
 
 #define SCM_CLOSUREP(a) (SCM_TYPE(a) == ScmClosure)
-#define SCM_AS_CLOSURE(a)  (sigassert(SCM_CLOSUREP(a)), (a))
 #define SCM_ENTYPE_CLOSURE(a) (SCM_ENTYPE((a), ScmClosure))
 #define SCM_CLOSURE_EXP(a) (SCM_AS_CLOSURE(a)->obj.closure.exp)
 #define SCM_CLOSURE_SET_EXP(a, exp) (SCM_CLOSURE_EXP(a) = exp)
@@ -350,7 +376,6 @@
 #define SCM_CLOSURE_SET_ENV(a, env) (SCM_CLOSURE_ENV(a) = env)
 
 #define SCM_VECTORP(a) (SCM_TYPE(a) == ScmVector)
-#define SCM_AS_VECTOR(a)  (sigassert(SCM_VECTORP(a)), (a))
 #define SCM_ENTYPE_VECTOR(a) (SCM_ENTYPE((a), ScmVector))
 #define SCM_VECTOR_VEC(a) (SCM_AS_VECTOR(a)->obj.vector.vec)
 #define SCM_VECTOR_SET_VEC(a, vec) (SCM_VECTOR_VEC(a) = (vec))
@@ -363,7 +388,6 @@
 #define SCM_VECTOR_CHECK_IDX(a, idx) ()
 
 #define SCM_PORTP(a) (SCM_TYPE(a) == ScmPort)
-#define SCM_AS_PORT(a)  (sigassert(SCM_PORTP(a)), (a))
 #define SCM_ENTYPE_PORT(a) (SCM_ENTYPE((a), ScmPort))
 #define SCM_PORT_PORTDIRECTION(a) (SCM_AS_PORT(a)->obj.port.port_direction)
 #define SCM_PORT_SET_PORTDIRECTION(a, pdirection) (SCM_PORT_PORTDIRECTION(a) = pdirection)
@@ -378,14 +402,12 @@
 #define SCM_PORTINFO_UNGOTTENCHAR(a) (SCM_PORT_PORTINFO(a)->ungottenchar)
 
 #define SCM_CONTINUATIONP(a) (SCM_TYPE(a) == ScmContinuation)
-#define SCM_AS_CONTINUATION(a)  (sigassert(SCM_CONTINUATIONP(a)), (a))
 #define SCM_ENTYPE_CONTINUATION(a) (SCM_ENTYPE((a), ScmContinuation))
 #define SCM_CONTINUATION_CONTINFO(a) (SCM_AS_CONTINUATION(a)->obj.continuation.cont_info)
 #define SCM_CONTINUATION_JMPENV(a) (SCM_AS_CONTINUATION(a)->obj.continuation.cont_info->jmp_env)
 #define SCM_CONTINUATION_SET_CONTINFO(a, cinfo) (SCM_CONTINUATION_CONTINFO(a) = (cinfo))
 
 #define SCM_VALUEPACKETP(a)          (SCM_TYPE(a) == ScmValuePacket)
-#define SCM_AS_VALUEPACKET(a)           (sigassert(SCM_VALUEPACKETP(a)), (a))
 #define SCM_ENTYPE_VALUEPACKET(a)        (SCM_ENTYPE((a), ScmValuePacket))
 #define SCM_VALUEPACKET_VALUES(a)    (SCM_AS_VALUEPACKET(a)->obj.value_pack.values)
 #define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_VALUEPACKET_VALUES(a) = (v))
@@ -394,7 +416,6 @@
   Etcetra Variables (Special Constants like SCM_NULL)
 ============================================================================*/
 #define SCM_ETCP(a) (SCM_TYPE(a) == ScmEtc)
-#define SCM_AS_ETC(a) (sigassert(SCM_ETCP(a)), (a))
 #define SCM_ETC_SET_IMPL(a, impl)         \
     do {                                  \
         (a) = &(impl);                    \
@@ -405,13 +426,11 @@
   C Pointer Object
 ============================================================================*/
 #define SCM_C_POINTERP(a) (SCM_TYPE(a) == ScmCPointer)
-#define SCM_AS_C_POINTER(a)  (sigassert(SCM_C_POINTERP(a)), (a))
 #define SCM_ENTYPE_C_POINTER(a) (SCM_ENTYPE((a), ScmCPointer))
 #define SCM_C_POINTER_VALUE(a) (SCM_AS_C_POINTER(a)->obj.c_pointer.data)
 #define SCM_C_POINTER_SET_VALUE(a, ptr) (SCM_C_POINTER_VALUE(a) = ptr)
 
 #define SCM_C_FUNCPOINTERP(a) (SCM_TYPE(a) == ScmCFuncPointer)
-#define SCM_AS_C_FUNCPOINTER(a)  (sigassert(SCM_C_FUNCPOINTERP(a)), (a))
 #define SCM_ENTYPE_C_FUNCPOINTER(a) (SCM_ENTYPE((a), ScmCFuncPointer))
 #define SCM_C_FUNCPOINTER_VALUE(a) (SCM_AS_C_FUNCPOINTER(a)->obj.c_func_pointer.func)
 #define SCM_C_FUNCPOINTER_SET_VALUE(a, funcptr) (SCM_C_FUNCPOINTER_VALUE(a) = funcptr)

Modified: branches/r5rs/sigscheme/test/test-num.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-num.scm	2005-08-29 08:53:13 UTC (rev 1350)
+++ branches/r5rs/sigscheme/test/test-num.scm	2005-08-29 09:17:18 UTC (rev 1351)
@@ -22,6 +22,14 @@
 
 ;; TODO: add tests for <, >=, <=
 
+(assert-equal? "max test1" 0 (max 0))
+(assert-equal? "max test2" 1 (max 0 1))
+(assert-equal? "max test3" 2 (max 0 2 1))
+(assert-equal? "max test4" 7 (max -1 -10 7))
+(assert-equal? "min test1" 0 (min 0))
+(assert-equal? "min test2" 0 (min 0 1))
+(assert-equal? "min test3" 0 (min 2 0 1))
+(assert-equal? "min test4" -10 (min -1 -10 7))
 (assert-equal? "+ test1" 0  (+))
 (assert-equal? "+ test2" 3  (+ 3))
 (assert-equal? "+ test3" 3  (+ 1 2))



More information about the uim-commit mailing list