BSB Developer Docs
Loading...
Searching...
No Matches
js_runner_i.h
Go to the documentation of this file.
1
6#pragma once
7#include "js_runner.h"
8#include "js_util.h"
9#include "js_runner_types.h"
10#include <furi/furi.h>
11#include <storage/storage.h>
12#include <path.h>
13#include <fetch/fetch.h>
14
15#pragma GCC diagnostic push
16#pragma GCC diagnostic ignored "-Wattributes"
17#include <jerryscript.h>
18#pragma GCC diagnostic pop
19
20// #define JS_DEBUG
21
22#if defined(JS_DEBUG)
23#define JS_TRACE(...) FURI_LOG_D(TAG, __VA_ARGS__)
24#else
25#define JS_TRACE(...)
26#endif
27
28#define MIN_INTERVAL_DELAY_MS 10.0f
29#define MAX_FETCH_MESSAGES 32
30#define MAX_COMMAND_MESSAGES 4
31
32#define APP_THREAD_STACK_SIZE (8 * 1024)
33
34#define JS_RUNNER_APP_FLAG_IDLE 1
35
36#define PTR_HASH(p) ((size_t)(p))
37
38extern JsRunnerStaticContext js_runner_static_context;
39
40#define WITH_JS_RUNNER_APP(APP, BLOCK) \
41 do { \
42 JsRunnerApp* APP = js_runner_static_context.app; \
43 furi_assert(APP->thread == furi_thread_get_current()); \
44 BLOCK \
45 } while(false)
46
47#define JS_ARG(n) (args[(n)])
48#define JS_ARG_OR_UNDEFINED(n) (args_count > (n) ? args[(n)] : jerry_undefined())
49
50void js_runner_app_stop_if_done(JsRunnerApp* app);
51void js_run_jobs(void);
52
57size_t js_runner_thread_context_alloc(size_t context_size);
58
64
70
71void js_runner_handle_fatal_error(jerry_fatal_code_t code);
72
77bool js_runner_get_root_path(FuriString* path);
78
79void js_runner_add_fetch_thread(JsRunnerApp* app, JsFetch* fetch);
80void js_runner_del_fetch_thread(JsRunnerApp* app, JsFetch* fetch);
81
82const char* js_runner_app_get_id(const JsRunnerApp* app);
83
84void js_runner_heap_destructor(void* object, void* user_p);
85
87void js_runner_defer(JsRunnerApp* app, JsRunnerDeferredCallback cb, void* context);
88
90void js_runner_cancel_defer(JsRunnerApp* app, JsRunnerDeferredCallback cb, void* context);
Library for building fetch-like HTTP clients.
Javascript app runner.
void js_runner_defer(JsRunnerApp *app, JsRunnerDeferredCallback cb, void *context)
Defer execution of a callback until before jerry_cleanup.
Definition js_runner.c:954
void * js_runner_thread_context_get(void)
Get Jerryscript context for current thread.
Definition js_runner.c:39
void js_runner_thread_context_free(void)
Free Jerryscript context for current thread.
Definition js_runner.c:31
size_t js_runner_thread_context_alloc(size_t context_size)
Allocate Jerryscript context for current thread.
Definition js_runner.c:21
void js_runner_cancel_defer(JsRunnerApp *app, JsRunnerDeferredCallback cb, void *context)
Cancel a deferred callback execution.
Definition js_runner.c:958
bool js_runner_get_root_path(FuriString *path)
Get root path of the current JS app (folder containing entry point).
Definition js_runner.c:67
Utility functions for working with JS values.
Filesystem path utilities.
APIs for working with storages, directories and files.
Definition js_fetch.h:78
Definition js_runner_types.h:99
Definition js_runner_types.h:145