mirror of
https://github.com/janet-lang/janet
synced 2025-11-05 10:03:06 +00:00
Change c function macros to be explicitly non functional by
capitalizing them.
This commit is contained in:
@@ -35,8 +35,8 @@ const char dst_base64[65] =
|
||||
* mnemonics instead of a bit pattern for type checking */
|
||||
const char *const dst_type_names[16] = {
|
||||
":nil",
|
||||
":false",
|
||||
":true",
|
||||
":boolean",
|
||||
":boolean",
|
||||
":fiber",
|
||||
":integer",
|
||||
":real",
|
||||
@@ -209,18 +209,18 @@ int dst_hashtable_view(Dst tab, const DstKV **data, int32_t *len, int32_t *cap)
|
||||
/* Get actual type name of a value for debugging purposes */
|
||||
static const char *typestr(DstArgs args, int32_t n) {
|
||||
DstType actual = n < args.n ? dst_type(args.v[n]) : DST_NIL;
|
||||
return (actual == DST_ABSTRACT)
|
||||
return ((actual == DST_ABSTRACT)
|
||||
? dst_abstract_type(dst_unwrap_abstract(args.v[n]))->name
|
||||
: dst_type_names[actual];
|
||||
: dst_type_names[actual]) + 1;
|
||||
}
|
||||
|
||||
int dst_type_err(DstArgs args, int32_t n, DstType expected) {
|
||||
const uint8_t *message = dst_formatc(
|
||||
"bad argument #%d, expected %t, got %s",
|
||||
"bad slot #%d, expected %t, got %s",
|
||||
n,
|
||||
expected,
|
||||
typestr(args, n));
|
||||
return dst_throwv(args, dst_wrap_string(message));
|
||||
DST_THROWV(args, dst_wrap_string(message));
|
||||
}
|
||||
|
||||
int dst_typemany_err(DstArgs args, int32_t n, int expected) {
|
||||
@@ -229,7 +229,7 @@ int dst_typemany_err(DstArgs args, int32_t n, int expected) {
|
||||
const uint8_t *message;
|
||||
DstBuffer buf;
|
||||
dst_buffer_init(&buf, 20);
|
||||
dst_buffer_push_string(&buf, dst_formatc("bad argument #%d, expected ", n));
|
||||
dst_buffer_push_string(&buf, dst_formatc("bad slot #%d, expected ", n));
|
||||
i = 0;
|
||||
while (expected) {
|
||||
if (1 & expected) {
|
||||
@@ -247,19 +247,19 @@ int dst_typemany_err(DstArgs args, int32_t n, int expected) {
|
||||
dst_buffer_push_cstring(&buf, typestr(args, n));
|
||||
message = dst_string(buf.data, buf.count);
|
||||
dst_buffer_deinit(&buf);
|
||||
return dst_throwv(args, dst_wrap_string(message));
|
||||
DST_THROWV(args, dst_wrap_string(message));
|
||||
}
|
||||
|
||||
int dst_arity_err(DstArgs args, int32_t n, const char *prefix) {
|
||||
return dst_throwv(args,
|
||||
DST_THROWV(args,
|
||||
dst_wrap_string(dst_formatc(
|
||||
"expected %s%d argument%s, got %d",
|
||||
prefix, n, n == 1 ? "" : "s", args.n)));
|
||||
}
|
||||
|
||||
int dst_typeabstract_err(DstArgs args, int32_t n, const DstAbstractType *at) {
|
||||
return dst_throwv(args,
|
||||
DST_THROWV(args,
|
||||
dst_wrap_string(dst_formatc(
|
||||
"bad argument #%d, expected %s, got %s",
|
||||
"bad slot #%d, expected %s, got %s",
|
||||
n, at->name, typestr(args, n))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user