-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.h
More file actions
31 lines (25 loc) · 826 Bytes
/
array.h
File metadata and controls
31 lines (25 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef sqript_array_h
#define sqript_array_h
#include "value.h"
#include "object.h"
#define IS_ARRAY(value) matchPtrType(value, PTR_ARRAY)
#define AS_ARRAY(value) ((PtrArray*)AS_PTR(value))
typedef struct {
Ptr ptr;
int length;
bool fixedSize;
ValueType type;
Value* values;
} PtrArray;
PtrArray* createArray(int length, ValueType type);
Value arrayGet(PtrArray* array, int index);
bool arraySet(PtrArray* array, int index, Value value);
void freeArray(PtrArray* array);
PtrArray* arraySpan(PtrArray* arr, int from, int length);
void arrayAppend(PtrArray* array, Value value);
void arrayRemoveAt(PtrArray* arr, int index);
void arrayRemove(PtrArray* arr, Value value);
void arrayInsert(PtrArray* arr, int index, Value value);
int arrayLength(PtrArray* array);
void freeArray(PtrArray* array);
#endif