2023-04-19 16:23:33 -07:00
|
|
|
#ifndef SFALL_ARRAYS
|
|
|
|
#define SFALL_ARRAYS
|
|
|
|
|
|
|
|
#include "interpreter.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace fallout {
|
|
|
|
|
|
|
|
#define SFALL_ARRAYFLAG_ASSOC (1) // is map
|
|
|
|
#define SFALL_ARRAYFLAG_CONSTVAL (2) // don't update value of key if the key exists in map
|
|
|
|
#define SFALL_ARRAYFLAG_RESERVED (4)
|
|
|
|
|
|
|
|
using ArrayId = unsigned int;
|
|
|
|
|
|
|
|
ArrayId CreateArray(int len, uint32_t flags);
|
|
|
|
ArrayId CreateTempArray(int len, uint32_t flags);
|
2023-05-14 11:54:41 -07:00
|
|
|
ProgramValue GetArrayKey(ArrayId array_id, int index, Program* program);
|
2023-04-19 16:23:33 -07:00
|
|
|
int LenArray(ArrayId array_id);
|
2023-05-14 11:54:41 -07:00
|
|
|
ProgramValue GetArray(ArrayId array_id, const ProgramValue& key, Program* program);
|
|
|
|
void SetArray(ArrayId array_id, const ProgramValue& key, const ProgramValue& val, bool allowUnset, Program* program);
|
2023-04-19 16:46:24 -07:00
|
|
|
void FreeArray(ArrayId array_id);
|
2023-04-19 16:53:49 -07:00
|
|
|
void FixArray(ArrayId id);
|
2023-04-23 10:29:45 -07:00
|
|
|
void ResizeArray(ArrayId array_id, int newLen);
|
2023-04-19 16:46:24 -07:00
|
|
|
void DeleteAllTempArrays();
|
2023-04-19 23:34:53 -07:00
|
|
|
void sfallArraysReset();
|
2023-05-14 11:54:41 -07:00
|
|
|
int StackArray(const ProgramValue& key, const ProgramValue& val, Program* program);
|
|
|
|
ProgramValue ScanArray(ArrayId array_id, const ProgramValue& val, Program* program);
|
2023-04-19 23:34:53 -07:00
|
|
|
|
2023-05-15 07:50:49 -07:00
|
|
|
ArrayId StringSplit(const char* str, const char* split);
|
|
|
|
|
2023-04-19 16:23:33 -07:00
|
|
|
}
|
|
|
|
#endif /* SFALL_ARRAYS */
|