1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

JS: Fix merge of 3963 and 3961 (#3980)

* toString() was moved, not duplicated
* These had gotten lost
* This is now implemented
* Add missing version doctags
This commit is contained in:
WillyJL
2024-11-01 04:52:54 +00:00
committed by GitHub
parent f4887ed31c
commit 69aa4cd254
4 changed files with 64 additions and 19 deletions

View File

@@ -217,16 +217,6 @@ static void js_parse_int(struct mjs* mjs) {
mjs_return(mjs, mjs_mk_number(mjs, num));
}
static void js_global_to_string(struct mjs* mjs) {
int base = 10;
if(mjs_nargs(mjs) > 1) base = mjs_get_int(mjs, mjs_arg(mjs, 1));
double num = mjs_get_int(mjs, mjs_arg(mjs, 0));
char tmp_str[] = "-2147483648";
itoa(num, tmp_str, base);
mjs_val_t ret = mjs_mk_string(mjs, tmp_str, ~0, true);
mjs_return(mjs, ret);
}
#ifdef JS_DEBUG
static void js_dump_write_callback(void* ctx, const char* format, ...) {
File* file = ctx;
@@ -278,7 +268,6 @@ static int32_t js_thread(void* arg) {
JS_ASSIGN_MULTI(mjs, global) {
JS_FIELD("print", MJS_MK_FN(js_print));
JS_FIELD("delay", MJS_MK_FN(js_delay));
JS_FIELD("toString", MJS_MK_FN(js_global_to_string));
JS_FIELD("parseInt", MJS_MK_FN(js_parse_int));
JS_FIELD("ffi_address", MJS_MK_FN(js_ffi_address));
JS_FIELD("require", MJS_MK_FN(js_require));