[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>
2024-02-12 11:54:32 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Cesanta Software Limited
|
|
|
|
* All rights reserved
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MJS_OBJECT_H_
|
|
|
|
#define MJS_OBJECT_H_
|
|
|
|
|
|
|
|
#include "mjs_object_public.h"
|
|
|
|
#include "mjs_internal.h"
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
struct mjs;
|
|
|
|
|
|
|
|
struct mjs_property {
|
|
|
|
struct mjs_property* next; /* Linkage in struct mjs_object::properties */
|
|
|
|
mjs_val_t name; /* Property name (a string) */
|
|
|
|
mjs_val_t value; /* Property value */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mjs_object {
|
|
|
|
struct mjs_property* properties;
|
|
|
|
};
|
|
|
|
|
|
|
|
MJS_PRIVATE struct mjs_object* get_object_struct(mjs_val_t v);
|
|
|
|
MJS_PRIVATE struct mjs_property*
|
|
|
|
mjs_get_own_property(struct mjs* mjs, mjs_val_t obj, const char* name, size_t len);
|
|
|
|
|
|
|
|
MJS_PRIVATE struct mjs_property*
|
|
|
|
mjs_get_own_property_v(struct mjs* mjs, mjs_val_t obj, mjs_val_t key);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A worker function for `mjs_set()` and `mjs_set_v()`: it takes name as both
|
|
|
|
* ptr+len and mjs_val_t. If `name` pointer is not NULL, it takes precedence
|
|
|
|
* over `name_v`.
|
|
|
|
*/
|
|
|
|
MJS_PRIVATE mjs_err_t mjs_set_internal(
|
|
|
|
struct mjs* mjs,
|
|
|
|
mjs_val_t obj,
|
|
|
|
mjs_val_t name_v,
|
|
|
|
char* name,
|
|
|
|
size_t name_len,
|
|
|
|
mjs_val_t val);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of `Object.create(proto)`
|
|
|
|
*/
|
|
|
|
MJS_PRIVATE void mjs_op_create_object(struct mjs* mjs);
|
|
|
|
|
[FL-3893] JS modules (#3841)
* feat: backport js_gpio from unleashed
* feat: backport js_keyboard, TextInputModel::minimum_length from unleashed
* fix: api version inconsistency
* style: js_gpio
* build: fix submodule ._ .
* refactor: js_gpio
* docs: type declarations for gpio
* feat: gpio interrupts
* fix: js_gpio freeing, resetting and minor stylistic changes
* style: js_gpio
* style: mlib array, fixme's
* feat: js_gpio adc
* feat: js_event_loop
* docs: js_event_loop
* feat: js_event_loop subscription cancellation
* feat: js_event_loop + js_gpio integration
* fix: js_event_loop memory leak
* feat: stop event loop on back button
* test: js: basic, math, event_loop
* feat: js_event_loop queue
* feat: js linkage to previously loaded plugins
* build: fix ci errors
* feat: js module ordered teardown
* feat: js_gui_defer_free
* feat: basic hourglass view
* style: JS ASS (Argument Schema for Scripts)
* fix: js_event_loop mem leaks and lifetime problems
* fix: crashing test and pvs false positives
* feat: mjs custom obj destructors, gui submenu view
* refactor: yank js_gui_defer_free (yuck)
* refactor: maybe_unsubscribe
* empty_screen, docs, typing fix-ups
* docs: navigation event & demo
* feat: submenu setHeader
* feat: text_input
* feat: text_box
* docs: text_box availability
* ci: silence irrelevant pvs low priority warning
* style: use furistring
* style: _get_at -> _safe_get
* fix: built-in module name assignment
* feat: js_dialog; refactor, optimize: js_gui
* docs: js_gui
* ci: silence pvs warning: Memory allocation is infallible
* style: fix storage spelling
* feat: foreign pointer signature checks
* feat: js_storage
* docs: js_storage
* fix: my unit test was breaking other tests ;_;
* ci: fix ci?
* Make doxygen happy
* docs: flipper, math, notification, global
* style: review suggestions
* style: review fixups
* fix: badusb demo script
* docs: badusb
* ci: add nofl
* ci: make linter happy
* Bump api version
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2024-10-14 21:42:11 +03:00
|
|
|
/*
|
|
|
|
* Cell destructor for object arena
|
|
|
|
*/
|
|
|
|
MJS_PRIVATE void mjs_obj_destructor(struct mjs* mjs, void* cell);
|
|
|
|
|
[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>
2024-02-12 11:54:32 +03:00
|
|
|
#define MJS_PROTO_PROP_NAME "__p" /* Make it < 5 chars */
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* MJS_OBJECT_H_ */
|