mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-13 13:09:49 +04:00
[FL-3579, FL-3601, FL-3714] JavaScript runner (#3286)
* FBT: cdefines to env, libs order * API: strtod, modf, itoa, calloc * Apps: elk js * Apps: mjs * JS: scripts as assets * mjs: composite resolver * mjs: stack trace * ELK JS example removed * MJS thread, MJS lib modified to support script interruption * JS console UI * Module system, BadUSB bindings rework * JS notifications, simple dialog, BadUSB demo * Custom dialogs, dialog demo * MJS as system library, some dirty hacks to make it compile * Plugin-based js modules * js_uart(BadUART) module * js_uart: support for byte array arguments * Script icon and various fixes * File browser: multiple extensions filter, running js scripts from app loader * Running js scripts from archive browser * JS Runner as system app * Example scripts moved to /ext/apps/Scripts * JS bytecode listing generation * MJS builtin printf cleanup * JS examples cleanup * mbedtls version fix * Unused lib cleanup * Making PVS happy & TODOs cleanup * TODOs cleanup #2 * MJS: initial typed arrays support * JS: fix mem leak in uart destructor Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
47
lib/mjs/mjs_array_public.h
Normal file
47
lib/mjs/mjs_array_public.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Cesanta Software Limited
|
||||
* All rights reserved
|
||||
*/
|
||||
|
||||
/*
|
||||
* === Arrays
|
||||
*/
|
||||
|
||||
#ifndef MJS_ARRAY_PUBLIC_H_
|
||||
#define MJS_ARRAY_PUBLIC_H_
|
||||
|
||||
#include "mjs_core_public.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Make an empty array object */
|
||||
mjs_val_t mjs_mk_array(struct mjs* mjs);
|
||||
|
||||
/* Returns length on an array. If `arr` is not an array, 0 is returned. */
|
||||
unsigned long mjs_array_length(struct mjs* mjs, mjs_val_t arr);
|
||||
|
||||
/* Insert value `v` in array `arr` at the end of the array. */
|
||||
mjs_err_t mjs_array_push(struct mjs* mjs, mjs_val_t arr, mjs_val_t v);
|
||||
|
||||
/*
|
||||
* Return array member at index `index`. If `index` is out of bounds, undefined
|
||||
* is returned.
|
||||
*/
|
||||
mjs_val_t mjs_array_get(struct mjs*, mjs_val_t arr, unsigned long index);
|
||||
|
||||
/* Insert value `v` into `arr` at index `index`. */
|
||||
mjs_err_t mjs_array_set(struct mjs* mjs, mjs_val_t arr, unsigned long index, mjs_val_t v);
|
||||
|
||||
/* Returns true if the given value is an array */
|
||||
int mjs_is_array(mjs_val_t v);
|
||||
|
||||
/* Delete value in array `arr` at index `index`, if it exists. */
|
||||
void mjs_array_del(struct mjs* mjs, mjs_val_t arr, unsigned long index);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* MJS_ARRAY_PUBLIC_H_ */
|
||||
Reference in New Issue
Block a user