diff --git a/c/external.c b/c/external.c index b001048..51e3e4e 100644 --- a/c/external.c +++ b/c/external.c @@ -473,12 +473,12 @@ s48_raise_scheme_exception(long why, long nargs, ...) /* Specific exceptions */ void -s48_raise_argtype_error(s48_value value) { +s48_raise_argument_type_error(s48_value value) { s48_raise_scheme_exception(S48_EXCEPTION_WRONG_TYPE_ARGUMENT, 1, value); } void -s48_raise_argnumber_error(s48_value value, s48_value min, s48_value max) { +s48_raise_argument_number_error(s48_value value, s48_value min, s48_value max) { s48_raise_scheme_exception(S48_EXCEPTION_WRONG_NUMBER_OF_ARGUMENTS, 3, value, min, max); } @@ -582,7 +582,7 @@ long s48_stob_length(s48_value thing, int type) { if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); return S48_STOB_DESCRIPTOR_LENGTH(thing); } @@ -591,7 +591,7 @@ long s48_stob_byte_length(s48_value thing, int type) { if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); if (type == S48_STOBTYPE_STRING) return S48_STOB_BYTE_LENGTH(thing) - 1; @@ -605,7 +605,7 @@ s48_stob_ref(s48_value thing, int type, long offset) long length; if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); length = S48_STOB_DESCRIPTOR_LENGTH(thing); @@ -625,7 +625,7 @@ s48_stob_set(s48_value thing, int type, long offset, s48_value value) if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type) && !S48_STOB_IMMUTABLEP(thing))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); length = S48_STOB_DESCRIPTOR_LENGTH(thing); @@ -643,7 +643,7 @@ s48_stob_byte_ref(s48_value thing, int type, long offset) long length; if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); length = (type == S48_STOBTYPE_STRING) ? S48_STOB_BYTE_LENGTH(thing) - 1 : @@ -663,7 +663,7 @@ s48_stob_byte_set(s48_value thing, int type, long offset, char value) long length; if (!(S48_STOB_P(thing) && (S48_STOB_TYPE(thing) == type))) - s48_raise_argtype_error(thing); + s48_raise_argument_type_error(thing); length = (type == S48_STOBTYPE_STRING) ? S48_STOB_BYTE_LENGTH(thing) - 1 : @@ -698,7 +698,7 @@ s48_value s48_enter_fixnum(long value) { if (value < S48_MIN_FIXNUM_VALUE || S48_MAX_FIXNUM_VALUE < value) - s48_raise_argtype_error(s48_enter_integer(value)); + s48_raise_argument_type_error(s48_enter_integer(value)); return S48_UNSAFE_ENTER_FIXNUM(value); } @@ -707,7 +707,7 @@ long s48_extract_fixnum(s48_value value) { if (! S48_FIXNUM_P(value)) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); return S48_UNSAFE_EXTRACT_FIXNUM(value); } @@ -786,7 +786,7 @@ s48_extract_integer(s48_value value) S48_GC_UNPROTECT(); if (stuff == S48_FALSE) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); /* The first VECTOR_REF does the type checking for the rest. */ { @@ -797,7 +797,7 @@ s48_extract_integer(s48_value value) if ((! S48_FIXNUM_P(boxed_high)) || high > (pos_p ? 0x7FFF : 0x8000)) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); { long magnitude = ((- high) << 16) - low; @@ -814,7 +814,7 @@ s48_extract_unsigned_integer(s48_value value) if (S48_FIXNUM_P(value)){ temp = S48_UNSAFE_EXTRACT_FIXNUM(value); if (temp < 0) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); else return (unsigned long) temp; } else { @@ -832,7 +832,7 @@ s48_extract_unsigned_integer(s48_value value) S48_GC_UNPROTECT(); if (stuff == S48_FALSE) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); /* The first VECTOR_REF does the type checking for the rest. */ { @@ -844,7 +844,7 @@ s48_extract_unsigned_integer(s48_value value) if ((!pos_p) || (! S48_FIXNUM_P(boxed_high)) || (high > 0xFFFF)) - s48_raise_argtype_error(value); + s48_raise_argument_type_error(value); else return ((((unsigned long) high) << 16) + low); } } @@ -869,7 +869,7 @@ double s48_extract_double(s48_value s48_double) { if (! S48_DOUBLE_P(s48_double)) - s48_raise_argtype_error(s48_double); + s48_raise_argument_type_error(s48_double); return S48_UNSAFE_EXTRACT_DOUBLE(s48_double); } @@ -889,7 +889,7 @@ unsigned char s48_extract_char(s48_value a_char) { if (! S48_CHAR_P(a_char)) - s48_raise_argtype_error(a_char); + s48_raise_argument_type_error(a_char); return S48_UNSAFE_EXTRACT_CHAR(a_char); } @@ -1063,7 +1063,7 @@ s48_check_record_type(s48_value record, s48_value type_binding) if ((! S48_RECORD_P(record)) || (S48_UNSAFE_SHARED_BINDING_REF(type_binding) != S48_UNSAFE_RECORD_REF(record, -1))) - s48_raise_argtype_error(record); + s48_raise_argument_type_error(record); } long diff --git a/c/scheme48.h b/c/scheme48.h index 2035878..5b9411a 100644 --- a/c/scheme48.h +++ b/c/scheme48.h @@ -188,9 +188,10 @@ extern void * s48_value_pointer(s48_value); /* Exceptions */ extern void s48_raise_scheme_exception(long type, long nargs, ...); -extern void s48_raise_argtype_error(s48_value value); -extern void s48_raise_argnumber_error(s48_value value, - s48_value min, s48_value max); +extern void s48_raise_argument_type_error(s48_value value); +extern void s48_raise_argument_number_error(s48_value value, + s48_value min, + s48_value max); extern void s48_raise_range_error(s48_value value, s48_value min, s48_value max); extern void s48_raise_closed_channel_error(); @@ -211,17 +212,22 @@ extern void s48_raise_out_of_memory_error(); /* Type checking */ -#define S48_CHECK_PAIR(v) do { if (!S48_PAIR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_FIXNUM(v) do { if (!S48_FIXNUM_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_STRING(v) do { if (!S48_STRING_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_BYTE_VECTOR(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_CHANNEL(v) do { if (!S48_CHANNEL_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_RECORD(v) do { if (!S48_RECORD_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_VALUE(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_EXPORT_BINDING(v) do { if (!S48_EXPORT_BINDING_P(v)) s48_raise_argtype_error(v); } while (0) +#define S48_CHECK_PAIR(v) do { if (!S48_PAIR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_FIXNUM(v) do { if (!S48_FIXNUM_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_STRING(v) do { if (!S48_STRING_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_BYTE_VECTOR(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_CHANNEL(v) do { if (!S48_CHANNEL_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_RECORD(v) do { if (!S48_RECORD_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_VALUE(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_EXPORT_BINDING(v) do { if (!S48_EXPORT_BINDING_P(v)) s48_raise_argument_type_error(v); } while (0) #define S48_VALUE_P(v) (S48_BYTE_VECTOR_P(v)) +#define S48_TRUE_P(v) ((v) == S48_TRUE) +#define S48_FALSE_P(v) ((v) == S48_FALSE) +#define S48_EXTRACT_BOOLEAN(v) ((v) != S48_FALSE) +#define S48_ENTER_BOOLEAN(v) ((v) ? S48_TRUE : S48_FALSE) + extern void s48_check_record_type(s48_value record, s48_value type_binding); #define S48_SHARED_BINDING_CHECK(binding) \ @@ -262,8 +268,8 @@ extern void s48_check_record_type(s48_value record, s48_value type_binding); #define S48_ADDRESS_AFTER_HEADER(x, type) ((type *)((x) - S48_STOB_TAG)) #define S48_STOB_REF(x, i) (S48_ADDRESS_AFTER_HEADER(x, s48_value)[i]) #define S48_STOB_BYTE_REF(x, i) (((char *)S48_ADDRESS_AFTER_HEADER(x, s48_value))[i]) -#define S48_STOB_SET(x, i, v) do { s48_value __stob_set_x = (x); long __stob_set_i = (i); s48_value __stob_set_v = (v); if (S48_STOB_IMMUTABLEP(__stob_set_x)) s48_raise_argtype_error(__stob_set_x); else { S48_WRITE_BARRIER((__stob_set_x), (char *) (&S48_STOB_REF((__stob_set_x), (__stob_set_i))),(__stob_set_v)); *(&S48_STOB_REF((__stob_set_x), (__stob_set_i))) = (__stob_set_v); } } while (0) -#define S48_STOB_BYTE_SET(x, i, v) do { s48_value __stob_set_x = (x); long __stob_set_i = (i); char __stob_set_v = (v); if (S48_STOB_IMMUTABLEP(__stob_set_x)) s48_raise_argtype_error(__stob_set_x); else *(&S48_STOB_BYTE_REF((__stob_set_x), (__stob_set_i))) = (__stob_set_v); } while (0) +#define S48_STOB_SET(x, i, v) do { s48_value __stob_set_x = (x); long __stob_set_i = (i); s48_value __stob_set_v = (v); if (S48_STOB_IMMUTABLEP(__stob_set_x)) s48_raise_argument_type_error(__stob_set_x); else { S48_WRITE_BARRIER((__stob_set_x), (char *) (&S48_STOB_REF((__stob_set_x), (__stob_set_i))),(__stob_set_v)); *(&S48_STOB_REF((__stob_set_x), (__stob_set_i))) = (__stob_set_v); } } while (0) +#define S48_STOB_BYTE_SET(x, i, v) do { s48_value __stob_set_x = (x); long __stob_set_i = (i); char __stob_set_v = (v); if (S48_STOB_IMMUTABLEP(__stob_set_x)) s48_raise_argument_type_error(__stob_set_x); else *(&S48_STOB_BYTE_REF((__stob_set_x), (__stob_set_i))) = (__stob_set_v); } while (0) #define S48_STOB_TYPE(x) ((S48_STOB_HEADER(x)>>2)&31) #define S48_STOB_HEADER(x) (S48_STOB_REF((x),-1)) #define S48_STOB_ADDRESS(x) (&(S48_STOB_HEADER(x))) diff --git a/c/scheme48.h.in b/c/scheme48.h.in index 316c8e1..ed74cea 100644 --- a/c/scheme48.h.in +++ b/c/scheme48.h.in @@ -182,9 +182,10 @@ extern void * s48_value_pointer(s48_value); /* Exceptions */ extern void s48_raise_scheme_exception(long type, long nargs, ...); -extern void s48_raise_argtype_error(s48_value value); -extern void s48_raise_argnumber_error(s48_value value, - s48_value min, s48_value max); +extern void s48_raise_argument_type_error(s48_value value); +extern void s48_raise_argument_number_error(s48_value value, + s48_value min, + s48_value max); extern void s48_raise_range_error(s48_value value, s48_value min, s48_value max); extern void s48_raise_closed_channel_error(); @@ -205,17 +206,22 @@ extern void s48_raise_out_of_memory_error(); /* Type checking */ -#define S48_CHECK_PAIR(v) do { if (!S48_PAIR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_FIXNUM(v) do { if (!S48_FIXNUM_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_STRING(v) do { if (!S48_STRING_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_BYTE_VECTOR(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_CHANNEL(v) do { if (!S48_CHANNEL_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_RECORD(v) do { if (!S48_RECORD_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_VALUE(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argtype_error(v); } while (0) -#define S48_CHECK_EXPORT_BINDING(v) do { if (!S48_EXPORT_BINDING_P(v)) s48_raise_argtype_error(v); } while (0) +#define S48_CHECK_PAIR(v) do { if (!S48_PAIR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_FIXNUM(v) do { if (!S48_FIXNUM_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_STRING(v) do { if (!S48_STRING_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_BYTE_VECTOR(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_CHANNEL(v) do { if (!S48_CHANNEL_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_RECORD(v) do { if (!S48_RECORD_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_VALUE(v) do { if (!S48_BYTE_VECTOR_P(v)) s48_raise_argument_type_error(v); } while (0) +#define S48_CHECK_EXPORT_BINDING(v) do { if (!S48_EXPORT_BINDING_P(v)) s48_raise_argument_type_error(v); } while (0) #define S48_VALUE_P(v) (S48_BYTE_VECTOR_P(v)) +#define S48_TRUE_P(v) ((v) == S48_TRUE) +#define S48_FALSE_P(v) ((v) == S48_FALSE) +#define S48_EXTRACT_BOOLEAN(v) ((v) != S48_FALSE) +#define S48_ENTER_BOOLEAN(v) ((v) ? S48_TRUE : S48_FALSE) + extern void s48_check_record_type(s48_value record, s48_value type_binding); #define S48_SHARED_BINDING_CHECK(binding) \ diff --git a/scheme/link/generate-c-header.scm b/scheme/link/generate-c-header.scm index 122ffa9..69112b0 100644 --- a/scheme/link/generate-c-header.scm +++ b/scheme/link/generate-c-header.scm @@ -111,7 +111,7 @@ "long __stob_set_i = (i); " "s48_value __stob_set_v = (v); " "if (S48_STOB_IMMUTABLEP(__stob_set_x)) " - "s48_raise_argtype_error(__stob_set_x); " + "s48_raise_argument_type_error(__stob_set_x); " "else { " "S48_WRITE_BARRIER((__stob_set_x), " "(char *) (&S48_STOB_REF((__stob_set_x), (__stob_set_i)))," @@ -126,7 +126,7 @@ "long __stob_set_i = (i); " "char __stob_set_v = (v); " "if (S48_STOB_IMMUTABLEP(__stob_set_x)) " - "s48_raise_argtype_error(__stob_set_x); " + "s48_raise_argument_type_error(__stob_set_x); " "else " "*(&S48_STOB_BYTE_REF((__stob_set_x), (__stob_set_i))) = (__stob_set_v); " "} while (0)")) diff --git a/scsh/network1.c b/scsh/network1.c index 7206708..2472c80 100644 --- a/scsh/network1.c +++ b/scsh/network1.c @@ -70,7 +70,7 @@ s48_value scheme_bind(s48_value sock, s48_value family, s48_value scheme_name) return S48_UNSPECIFIC; } default: - s48_raise_argtype_error (family); + s48_raise_argument_type_error (family); } } @@ -140,7 +140,7 @@ s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_name } default: - s48_raise_argtype_error (family); /* error unknown address family */ + s48_raise_argument_type_error (family); /* error unknown address family */ } } /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ @@ -208,7 +208,7 @@ s48_value scheme_accept(s48_value sockfd_tagged, s48_value family) break; } default: - s48_raise_argtype_error (family); /* error unknown address family */ + s48_raise_argument_type_error (family); /* error unknown address family */ } } @@ -242,7 +242,7 @@ s48_value scheme_peer_name(s48_value sock, s48_value family) break; } default: - s48_raise_argtype_error (family); /* error unknown address family */ + s48_raise_argument_type_error (family); /* error unknown address family */ } } /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ @@ -274,7 +274,7 @@ s48_value scheme_socket_name(s48_value sock, s48_value family) break; } default: - s48_raise_argtype_error (family); /* error unknown address family */ + s48_raise_argument_type_error (family); /* error unknown address family */ } } @@ -383,7 +383,7 @@ s48_value send_substring(s48_value scm_sockfd, break; } default: - s48_raise_argtype_error (s48_extract_fixnum (scm_family)); + s48_raise_argument_type_error (s48_extract_fixnum (scm_family)); /* error unknown address family */ } diff --git a/scsh/syscalls1.c b/scsh/syscalls1.c index a52bb84..3cc5243 100644 --- a/scsh/syscalls1.c +++ b/scsh/syscalls1.c @@ -862,7 +862,7 @@ s48_value errno_msg(s48_value sch_i) #endif char *sys_errlist[]; extern int sys_nerr; - return ( i < 0 || i > sys_nerr ) ? s48_raise_argtype_error(sch_i) + return ( i < 0 || i > sys_nerr ) ? s48_raise_argument_type_error(sch_i) : s48_enter_string (sys_errlist[i]); #endif /* !HAVE_STRERROR */ }