From: Bill Schottstaedt <bil@ccrma.Stanford.EDU>
Cc: bug-guile@gnu.org
Subject: Re: number->string of float with radix
Date: Sun, 20 Oct 2002 03:44:42 -0700 [thread overview]
Message-ID: <200210201044.DAA19994@cmn14.stanford.edu> (raw)
In-Reply-To: <87vg3z1kje.fsf@zagadka.ping.de>
> then incrementally replace uses of SCM_MAKE_VALIDATE with improved
> versions. Or use SCM_ASSERT_TYPE directly. Hmm.
It would not be hard to fix SCM_MAKE_VALIDATE entirely -- it's
only used in validate.h, async.c, modules.h, and goops.h; here's
a suggestion (I'm guessing in some cases -- see the "???"):
validate.h starting at line 138):
#define SCM_MAKE_VALIDATE2(pos, var, pred, msg) \
do { \
SCM_ASSERT_TYPE (SCM_ ## pred (var), var, pos, FUNC_NAME, msg); \
} while (0)
\f
#define SCM_VALIDATE_REST_ARGUMENT(x) \
do { \
if (SCM_DEBUG_REST_ARGUMENT) { \
if (scm_ilength (x) < 0) { \
SCM_MISC_ERROR ("Rest arguments do not form a proper list.", SCM_EOL); \
} \
} \
} while (0)
#define SCM_VALIDATE_NIM(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, NIMP, "variable") /* ??? */
#define SCM_VALIDATE_BOOL(pos, flag) SCM_MAKE_VALIDATE2(pos, flag, BOOLP, "boolean")
#define SCM_VALIDATE_BOOL_COPY(pos, flag, cvar) \
do { \
SCM_ASSERT (SCM_BOOLP (flag), flag, pos, FUNC_NAME); \
cvar = SCM_EQ_P (flag, SCM_BOOL_T) ? 1 : 0; \
} while (0)
#define SCM_VALIDATE_CHAR(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, CHARP, "character")
#define SCM_VALIDATE_CHAR_COPY(pos, scm, cvar) \
do { \
SCM_ASSERT (SCM_CHARP (scm), scm, pos, FUNC_NAME); \
cvar = SCM_CHAR (scm); \
} while (0)
#define SCM_VALIDATE_STRING(pos, str) SCM_MAKE_VALIDATE2 (pos, str, STRINGP, "string")
#define SCM_VALIDATE_STRING_COPY(pos, str, cvar) \
do { \
SCM_ASSERT (SCM_STRINGP (str), str, pos, FUNC_NAME); \
cvar = SCM_STRING_CHARS(str); \
} while (0)
/* validate a string and optional start/end arguments which default to
0/string-len. this is unrelated to the old shared substring
support, so please do not deprecate it :) */
#define SCM_VALIDATE_SUBSTRING_SPEC_COPY(pos_str, str, c_str, \
pos_start, start, c_start,\
pos_end, end, c_end) \
do {\
SCM_VALIDATE_STRING_COPY (pos_str, str, c_str);\
SCM_VALIDATE_INUM_DEF_COPY (pos_start, start, 0, c_start);\
SCM_VALIDATE_INUM_DEF_COPY (pos_end, end, SCM_STRING_LENGTH (str), c_end);\
SCM_ASSERT_RANGE (pos_start, start,\
0 <= c_start \
&& (size_t) c_start <= SCM_STRING_LENGTH (str));\
SCM_ASSERT_RANGE (pos_end, end,\
c_start <= c_end \
&& (size_t) c_end <= SCM_STRING_LENGTH (str));\
} while (0)
#define SCM_VALIDATE_REAL(pos, z) SCM_MAKE_VALIDATE2 (pos, z, REALP, "real")
#define SCM_VALIDATE_NUMBER(pos, z) SCM_MAKE_VALIDATE2 (pos, z, NUMBERP, "number")
#define SCM_VALIDATE_INUM(pos, k) SCM_MAKE_VALIDATE2 (pos, k, INUMP, "exact integer")
#define SCM_VALIDATE_INUM_COPY(pos, k, cvar) \
do { \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
cvar = SCM_INUM (k); \
} while (0)
#define SCM_VALIDATE_USHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2USHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_SHORT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2SHORT (pos, k); \
} while (0)
#define SCM_VALIDATE_UINT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2UINT (pos, k); \
} while (0)
#define SCM_VALIDATE_INT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2INT (pos, k); \
} while (0)
#define SCM_VALIDATE_ULONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2ULONG (pos, k); \
} while (0)
#define SCM_VALIDATE_LONG_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2LONG (pos, k); \
} while (0)
#define SCM_VALIDATE_FLOAT_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2FLOAT (pos, k); \
} while (0)
#define SCM_VALIDATE_DOUBLE_COPY(pos, k, cvar) \
do { \
cvar = SCM_NUM2DOUBLE (pos, k); \
} while (0)
#define SCM_VALIDATE_BIGINT(pos, k) SCM_MAKE_VALIDATE2 (pos, k, BIGP, "bignum")
#define SCM_VALIDATE_INUM_MIN(pos, k, min) \
do { \
SCM_ASSERT (SCM_INUMP(k), k, pos, FUNC_NAME); \
SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
} while (0)
#define SCM_VALIDATE_INUM_MIN_COPY(pos, k, min, cvar) \
do { \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
cvar = SCM_INUM (k); \
} while (0)
#define SCM_VALIDATE_INUM_MIN_DEF_COPY(pos, k, min, default, cvar) \
do { \
if (SCM_UNBNDP (k)) \
k = SCM_MAKINUM (default); \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
SCM_ASSERT_RANGE (pos, k, (SCM_INUM (k) >= min)); \
cvar = SCM_INUM (k); \
} while (0)
#define SCM_VALIDATE_INUM_DEF(pos, k, default) \
do { \
if (SCM_UNBNDP (k)) \
k = SCM_MAKINUM (default); \
else SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_INUM_DEF_COPY(pos, k, default, cvar) \
do { \
if (SCM_UNBNDP (k)) \
{ \
k = SCM_MAKINUM (default); \
cvar = default; \
} \
else \
{ \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
cvar = SCM_INUM (k); \
} \
} while (0)
#define SCM_VALIDATE_DOUBLE_DEF_COPY(pos, k, default, cvar) \
do { \
if (SCM_UNBNDP (k)) \
{ \
k = scm_make_real (default); \
cvar = default; \
} \
else \
{ \
cvar = SCM_NUM2DOUBLE (pos, k); \
} \
} while (0)
/* [low, high) */
#define SCM_VALIDATE_INUM_RANGE(pos, k, low, high) \
do { SCM_ASSERT(SCM_INUMP(k), k, pos, FUNC_NAME); \
SCM_ASSERT_RANGE(pos, k, \
(SCM_INUM (k) >= low && \
SCM_INUM (k) < high)); \
} while (0)
#define SCM_VALIDATE_INUM_RANGE_COPY(pos, k, low, high, cvar) \
do { \
SCM_ASSERT (SCM_INUMP (k), k, pos, FUNC_NAME); \
SCM_ASSERT_RANGE (pos, k, low <= SCM_INUM (k) && SCM_INUM (k) < high); \
cvar = SCM_INUM (k); \
} while (0)
#define SCM_VALIDATE_NULL(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, NULLP, "null")
#define SCM_VALIDATE_NULL_OR_NIL(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, NULL_OR_NIL_P, "null or empty list") /* ??? */
#define SCM_VALIDATE_CONS(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, CONSP, "cons")
#define SCM_VALIDATE_LIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST(pos, lst) \
do { \
SCM_ASSERT (scm_ilength (lst) > 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_LIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 0, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NONEMPTYLIST_COPYLEN(pos, lst, cvar) \
do { \
cvar = scm_ilength (lst); \
SCM_ASSERT (cvar >= 1, lst, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_ALISTCELL(pos, alist) \
do { \
SCM_ASSERT (SCM_CONSP (alist) && SCM_CONSP (SCM_CAR (alist)), \
alist, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_ALISTCELL_COPYSCM(pos, alist, cvar) \
do { \
SCM_ASSERT (SCM_CONSP (alist), alist, pos, FUNC_NAME); \
cvar = SCM_CAR (alist); \
SCM_ASSERT (SCM_CONSP (cvar), alist, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_OPORT_VALUE(pos, port) \
do { \
SCM_ASSERT (scm_valid_oport_value_p (port), port, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_PRINTSTATE(pos, a) SCM_MAKE_VALIDATE2(pos, a, PRINT_STATE_P, "print-state")
#define SCM_VALIDATE_SMOB(pos, obj, type) \
do { \
SCM_ASSERT (SCM_TYP16_PREDICATE (scm_tc16_ ## type, obj), \
obj, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_THREAD(pos, a) SCM_MAKE_VALIDATE2 (pos, a, THREADP, "thread")
#define SCM_VALIDATE_THUNK(pos, thunk) \
do { \
SCM_ASSERT (!SCM_FALSEP (scm_thunk_p (thunk)), thunk, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_SYMBOL(pos, sym) SCM_MAKE_VALIDATE2 (pos, sym, SYMBOLP, "symbol")
#define SCM_VALIDATE_VARIABLE(pos, var) SCM_MAKE_VALIDATE2 (pos, var, VARIABLEP, "variable")
#define SCM_VALIDATE_MEMOIZED(pos, obj) SCM_MAKE_VALIDATE2 (pos, obj, MEMOIZEDP, "memoized entity") /* ??? */
#define SCM_VALIDATE_CLOSURE(pos, obj) SCM_MAKE_VALIDATE2 (pos, obj, CLOSUREP, "closure")
#define SCM_VALIDATE_PROC(pos, proc) \
do { \
SCM_ASSERT (SCM_EQ_P (scm_procedure_p (proc), SCM_BOOL_T), proc, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_NULLORCONS(pos, env) \
do { \
SCM_ASSERT (SCM_NULLP (env) || SCM_CONSP (env), env, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_HOOK(pos, a) SCM_MAKE_VALIDATE2 (pos, a, HOOKP, "hook")
#define SCM_VALIDATE_RGXP(pos, a) SCM_MAKE_VALIDATE2 (pos, a, RGXP, "regexp") /* ??? */
#define SCM_VALIDATE_DIR(pos, port) SCM_MAKE_VALIDATE2 (pos, port, DIRP, "directory") /* ??? */
#define SCM_VALIDATE_PORT(pos, port) SCM_MAKE_VALIDATE2 (pos, port, PORTP, "port")
#define SCM_VALIDATE_INPUT_PORT(pos, port) \
SCM_MAKE_VALIDATE2 (pos, port, INPUT_PORT_P, "input port")
#define SCM_VALIDATE_OUTPUT_PORT(pos, port) \
SCM_MAKE_VALIDATE2 (pos, port, OUTPUT_PORT_P, "output port")
#define SCM_VALIDATE_FPORT(pos, port) SCM_MAKE_VALIDATE2 (pos, port, FPORTP, "port") /* ??? */
#define SCM_VALIDATE_OPFPORT(pos, port) SCM_MAKE_VALIDATE2 (pos, port, OPFPORTP, "port") /* ??? */
#define SCM_VALIDATE_OPINPORT(pos, port) \
SCM_MAKE_VALIDATE2 (pos, port, OPINPORTP, "port") /* ??? */
#define SCM_VALIDATE_OPENPORT(pos, port) \
do { \
SCM_ASSERT (SCM_PORTP (port) && SCM_OPENP (port), \
port, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_OPPORT(pos, port) SCM_MAKE_VALIDATE2 (pos, port, OPPORTP, "port") /* ??? */
#define SCM_VALIDATE_OPOUTPORT(pos, port) \
SCM_MAKE_VALIDATE2 (pos, port, OPOUTPORTP, "port") /* ??? */
#define SCM_VALIDATE_OPOUTSTRPORT(pos, port) \
SCM_MAKE_VALIDATE2 (pos, port, OPOUTSTRPORTP, "port") /* ??? */
#define SCM_VALIDATE_FLUID(pos, fluid) SCM_MAKE_VALIDATE2 (pos, fluid, FLUIDP, "fluid")
#define SCM_VALIDATE_KEYWORD(pos, v) SCM_MAKE_VALIDATE2 (pos, v, KEYWORDP, "keyword")
#define SCM_VALIDATE_STACK(pos, v) SCM_MAKE_VALIDATE2 (pos, v, STACKP, "stack") /* ??? */
#define SCM_VALIDATE_FRAME(pos, v) SCM_MAKE_VALIDATE2 (pos, v, FRAMEP, "frame") /* ??? */
#define SCM_VALIDATE_RSTATE(pos, v) SCM_MAKE_VALIDATE2 (pos, v, RSTATEP, "random-number-state") /* ??? */
#define SCM_VALIDATE_ARRAY(pos, v) \
do { \
SCM_ASSERT (!SCM_IMP (v) \
&& !SCM_FALSEP (scm_array_p (v, SCM_UNDEFINED)), \
v, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_VECTOR(pos, v) SCM_MAKE_VALIDATE2 (pos, v, VECTORP, "vector")
#define SCM_VALIDATE_VECTOR_OR_DVECTOR(pos, v) \
do { \
SCM_ASSERT ((SCM_VECTORP (v) \
|| (!SCM_IMP (v) && SCM_TYP7 (v) == scm_tc7_dvect)), \
v, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_STRUCT(pos, v) SCM_MAKE_VALIDATE2 (pos, v, STRUCTP, "struct")
#define SCM_VALIDATE_VTABLE(pos, v) \
do { \
SCM_ASSERT (!SCM_IMP (v) && !SCM_FALSEP (scm_struct_vtable_p (v)), \
v, pos, FUNC_NAME); \
} while (0)
#define SCM_VALIDATE_VECTOR_LEN(pos, v, len) \
do { \
SCM_ASSERT (SCM_VECTORP (v) && len == SCM_VECTOR_LENGTH (v), v, pos, FUNC_NAME); \
} while (0)
#endif /* SCM_VALIDATE_H */
----------------
goops.h:
#define SCM_CLASSP(x) \
(SCM_STRUCTP (x) && SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_METACLASS)
#define SCM_VALIDATE_CLASS(pos, x) SCM_MAKE_VALIDATE2 (pos, x, CLASSP, "class")
#define SCM_INSTANCEP(x) \
(SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_GOOPS))
#define SCM_VALIDATE_INSTANCE(pos, x) SCM_MAKE_VALIDATE2 (pos, x, INSTANCEP, "instance")
#define SCM_PUREGENERICP(x) \
(SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_PURE_GENERIC))
#define SCM_VALIDATE_PUREGENERIC(pos, x) SCM_MAKE_VALIDATE2 (pos, x, PUREGENERICP, "generic") /* ??? */
#define SCM_ACCESSORP(x) \
(SCM_STRUCTP (x) && (SCM_STRUCT_VTABLE_FLAGS (x) & SCM_CLASSF_ACCESSOR_METHOD))
#define SCM_VALIDATE_ACCESSOR(pos, x) SCM_MAKE_VALIDATE2 (pos, x, ACCESSORP, "accessor") /* ??? */
#define SCM_SLOT(x, i) (SCM_PACK (SCM_INST (x) [i]))
#define SCM_SET_SLOT(x, i, v) (SCM_INST (x) [i] = SCM_UNPACK (v))
#define SCM_INSTANCE_HASH(c, i) (SCM_INST (c) [scm_si_hashsets + (i)])
#define SCM_SET_HASHSET(c, i, h) (SCM_INST (c) [scm_si_hashsets + (i)] = (h))
#define SCM_SUBCLASSP(c1, c2) (!SCM_FALSEP (scm_c_memq (c2, SCM_SLOT (c1, scm_si_cpl))))
#define SCM_IS_A_P(x, c) \
(SCM_INSTANCEP (x) && SCM_SUBCLASSP (SCM_CLASS_OF (x), c))
#define SCM_GENERICP(x) \
(SCM_INSTANCEP (x) && SCM_SUBCLASSP (SCM_CLASS_OF (x), scm_class_generic))
#define SCM_VALIDATE_GENERIC(pos, x) SCM_MAKE_VALIDATE2 (pos, x, GENERICP, "generic function") /* ??? */
#define SCM_METHODP(x) \
(SCM_INSTANCEP (x) && SCM_SUBCLASSP (SCM_CLASS_OF (x), scm_class_method))
#define SCM_VALIDATE_METHOD(pos, x) SCM_MAKE_VALIDATE2 (pos, x, METHODP, "method")
----------------
async.c:
#define VALIDATE_ASYNC(pos, a) SCM_MAKE_VALIDATE2(pos, a, ASYNCP, "async") /* ??? */
----------------
modules.h:
#define SCM_VALIDATE_MODULE(pos, scm) SCM_MAKE_VALIDATE2 (pos, scm, MODULEP, "module")
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
next prev parent reply other threads:[~2002-10-20 10:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-14 10:55 number->string of float with radix Bill Schottstaedt
2002-10-18 21:53 ` Marius Vollmer
2002-10-20 10:44 ` Bill Schottstaedt [this message]
2002-10-20 21:41 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200210201044.DAA19994@cmn14.stanford.edu \
--to=bil@ccrma.stanford.edu \
--cc=bug-guile@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).