luahl: global the luahl

This commit is contained in:
Björn Linse
2020-09-12 10:29:30 +02:00
parent 05c68922d3
commit 4042975df4
9 changed files with 144 additions and 104 deletions

View File

@@ -1618,3 +1618,15 @@ free_exit:
clear_virttext(&virt_text);
return virt_text;
}
bool api_is_truthy(Object obj, const char *what, Error *err)
{
if (obj.type == kObjectTypeBoolean) {
return obj.data.boolean;
} else if (obj.type == kObjectTypeInteger) {
return obj.data.integer; // C semantics: non-zery int is true
} else {
api_set_error(err, kErrorTypeValidation, "%s is not an boolean", what);
return false;
}
}