mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
0154018363
* 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>
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/*
|
|
* Copyright (c) 2016 Cesanta Software Limited
|
|
* All rights reserved
|
|
*/
|
|
|
|
#ifndef MJS_FFI_FFI_H_
|
|
#define MJS_FFI_FFI_H_
|
|
|
|
#include "../common/platform.h"
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
/*
|
|
* Maximum number of word-sized args to ffi-ed function. If at least one
|
|
* of the args is double, only 2 args are allowed.
|
|
*/
|
|
#define FFI_MAX_ARGS_CNT 6
|
|
|
|
typedef void(ffi_fn_t)(void);
|
|
|
|
typedef intptr_t ffi_word_t;
|
|
|
|
enum ffi_ctype {
|
|
FFI_CTYPE_WORD,
|
|
FFI_CTYPE_BOOL,
|
|
FFI_CTYPE_FLOAT,
|
|
FFI_CTYPE_DOUBLE,
|
|
};
|
|
|
|
struct ffi_arg {
|
|
enum ffi_ctype ctype;
|
|
union {
|
|
uint64_t i;
|
|
double d;
|
|
float f;
|
|
} v;
|
|
};
|
|
|
|
int ffi_call_mjs(ffi_fn_t* func, int nargs, struct ffi_arg* res, struct ffi_arg* args);
|
|
|
|
void ffi_set_word(struct ffi_arg* arg, ffi_word_t v);
|
|
void ffi_set_bool(struct ffi_arg* arg, bool v);
|
|
void ffi_set_ptr(struct ffi_arg* arg, void* v);
|
|
void ffi_set_double(struct ffi_arg* arg, double v);
|
|
void ffi_set_float(struct ffi_arg* arg, float v);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* MJS_FFI_FFI_H_ */
|