mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-30 08:20:21 +00:00
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
|
/*
|
||
|
* 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_ */
|