forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduk_harray.h
More file actions
59 lines (52 loc) · 1.68 KB
/
duk_harray.h
File metadata and controls
59 lines (52 loc) · 1.68 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Array object representation, used for actual Array instances.
*
* All objects with the exotic array behavior (which must coincide with having
* internal class array) MUST be duk_harrays. No other object can be a
* duk_harray. However, duk_harrays may not always have an array part.
*/
#if !defined(DUK_HARRAY_H_INCLUDED)
#define DUK_HARRAY_H_INCLUDED
#if defined(DUK_USE_ASSERTIONS)
DUK_INTERNAL_DECL void duk_harray_assert_valid(duk_harray *h);
#define DUK_HARRAY_ASSERT_VALID(h) \
do { \
duk_harray_assert_valid((h)); \
} while (0)
#else
#define DUK_HARRAY_ASSERT_VALID(h) \
do { \
} while (0)
#endif
#define DUK_HARRAY_LENGTH_WRITABLE(h) (!(h)->length_nonwritable)
#define DUK_HARRAY_LENGTH_NONWRITABLE(h) ((h)->length_nonwritable)
#define DUK_HARRAY_SET_LENGTH_WRITABLE(h) \
do { \
(h)->length_nonwritable = 0; \
} while (0)
#define DUK_HARRAY_SET_LENGTH_NONWRITABLE(h) \
do { \
(h)->length_nonwritable = 1; \
} while (0)
struct duk_harray {
/* Shared object part. */
duk_hobject obj;
/* Array .length.
*
* At present Array .length may be smaller, equal, or even larger
* than the allocated underlying array part. Fast path code must
* always take this into account carefully.
*/
duk_uint32_t length;
/* Array .length property attributes. The property is always
* non-enumerable and non-configurable. It's initially writable
* but per Object.defineProperty() rules it can be made non-writable
* even if it is non-configurable. Thus we need to track the
* writability explicitly.
*
* XXX: this field to be eliminated and moved into duk_hobject
* flags field to save space.
*/
duk_bool_t length_nonwritable;
};
#endif /* DUK_HARRAY_H_INCLUDED */