Simpler SIMPLE_ERRORS and new LOW_MEM FORCE_TEXT
This commit is contained in:
parent
3d8e2d30d4
commit
58f73bc0f8
|
@ -257,10 +257,16 @@ static void code_click_subscribe(void *context)
|
||||||
window_single_click_subscribe(BUTTON_ID_BACK, click_backspace);
|
window_single_click_subscribe(BUTTON_ID_BACK, click_backspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOW_MEM
|
||||||
|
#define DISPLAY_LINE " (hrt) \":\" (mnt))\n"
|
||||||
|
#else
|
||||||
|
#define DISPLAY_LINE " (hrt) \":\" (if (> 10 (mnt)) \"0\" \"\") (mnt))\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FORCE_TEXT \
|
#define FORCE_TEXT \
|
||||||
"(def time (fn () (utl tt \n"\
|
"(def time (fn () (utl tt \n"\
|
||||||
" (cat \"Hey, it's \" \n"\
|
" (cat \"Hey, it's \" \n"\
|
||||||
" (hrt) \":\" (mnt))\n"\
|
DISPLAY_LINE \
|
||||||
")))\n" \
|
")))\n" \
|
||||||
"(def ww (cw))\n" \
|
"(def ww (cw))\n" \
|
||||||
"(def tt (atl ww \":\"))\n" \
|
"(def tt (atl ww \":\"))\n" \
|
||||||
|
|
15
src/object.c
15
src/object.c
|
@ -195,6 +195,7 @@ void nf_addToList(Object *dest, const Object src)
|
||||||
allocObject(&tail(dest)->forward, src);
|
allocObject(&tail(dest)->forward, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERRORS
|
||||||
static const char *errorText[] = {
|
static const char *errorText[] = {
|
||||||
"MISMATCHED_PARENS",
|
"MISMATCHED_PARENS",
|
||||||
"BAD_LIST_OF_SYMBOL_STRINGS",
|
"BAD_LIST_OF_SYMBOL_STRINGS",
|
||||||
|
@ -219,17 +220,7 @@ static const char *errorText[] = {
|
||||||
"NO_CLONE_SPECIFIED",
|
"NO_CLONE_SPECIFIED",
|
||||||
"CAN_ONLY_EVAL_STRINGS"
|
"CAN_ONLY_EVAL_STRINGS"
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
/**
|
|
||||||
* Prints out the error of a given error Object
|
|
||||||
* Doesn't print anything if `obj` is NULL or not an error type
|
|
||||||
* @param obj A pointer to the Object to print
|
|
||||||
*/
|
|
||||||
void printErr(const Object *obj)
|
|
||||||
{
|
|
||||||
if(!obj || obj->type != TYPE_ERROR)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a string from a given list Object
|
* Creates a string from a given list Object
|
||||||
|
@ -294,7 +285,7 @@ char* stringNObj(char *dest, const Object *obj, const size_t len) {
|
||||||
case TYPE_ERROR: {
|
case TYPE_ERROR: {
|
||||||
int code = getErrorCode(*obj);
|
int code = getErrorCode(*obj);
|
||||||
#ifdef SIMPLE_ERRORS
|
#ifdef SIMPLE_ERRORS
|
||||||
snprintf(dest, len, "%s", errorText[code]);
|
snprintf(dest, len, "E[%d]", (int)code);
|
||||||
#else
|
#else
|
||||||
if (obj->error->context && obj->error->context[0] != '\0') {
|
if (obj->error->context && obj->error->context[0] != '\0') {
|
||||||
snprintf(dest, len, "'%s': %s",
|
snprintf(dest, len, "'%s': %s",
|
||||||
|
|
Loading…
Reference in New Issue