|
27 | 27 | */ |
28 | 28 |
|
29 | 29 | #if defined(DUK_USE_STRLEN16) |
30 | | -#define DUK_HSTRING_MAX_BYTELEN (0x0000ffffUL) |
| 30 | +#define DUK_HSTRING_MAX_BYTELEN (0x0000ffffUL) |
31 | 31 | #else |
32 | | -#define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) |
| 32 | +#define DUK_HSTRING_MAX_BYTELEN (0x7fffffffUL) |
33 | 33 | #endif |
34 | 34 |
|
35 | 35 | /* XXX: could add flags for "is valid CESU-8" (ECMAScript compatible strings), |
|
41 | 41 | /* With lowmem builds the high 16 bits of duk_heaphdr are used for other |
42 | 42 | * purposes, so this leaves 7 duk_heaphdr flags and 9 duk_hstring flags. |
43 | 43 | */ |
44 | | -#define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ |
45 | | -#define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ |
46 | | -#define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ |
47 | | -#define DUK_HSTRING_FLAG_HIDDEN DUK_HEAPHDR_USER_FLAG(3) /* string is a hidden symbol (implies symbol, Duktape 1.x internal string) */ |
48 | | -#define DUK_HSTRING_FLAG_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(4) /* string is a reserved word (non-strict) */ |
49 | | -#define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ |
50 | | -#define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ |
51 | | -#define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ |
52 | | -#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ |
53 | | - |
54 | | -#define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
55 | | -#define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
56 | | -#define DUK_HSTRING_HAS_SYMBOL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
57 | | -#define DUK_HSTRING_HAS_HIDDEN(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
58 | | -#define DUK_HSTRING_HAS_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
59 | | -#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
60 | | -#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
61 | | -#define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
62 | | -#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
63 | | - |
64 | | -#define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
65 | | -#define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
66 | | -#define DUK_HSTRING_SET_SYMBOL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
67 | | -#define DUK_HSTRING_SET_HIDDEN(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
68 | | -#define DUK_HSTRING_SET_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
69 | | -#define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
70 | | -#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
71 | | -#define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
72 | | -#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
73 | | - |
74 | | -#define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
75 | | -#define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
76 | | -#define DUK_HSTRING_CLEAR_SYMBOL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
77 | | -#define DUK_HSTRING_CLEAR_HIDDEN(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
78 | | -#define DUK_HSTRING_CLEAR_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
79 | | -#define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
80 | | -#define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
81 | | -#define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
82 | | -#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
83 | | - |
84 | | -#if 0 /* Slightly smaller code without explicit flag, but explicit flag |
85 | | - * is very useful when 'clen' is dropped. |
86 | | - */ |
87 | | -#define DUK_HSTRING_IS_ASCII(x) (DUK_HSTRING_GET_BYTELEN((x)) == DUK_HSTRING_GET_CHARLEN((x))) |
| 44 | +#define DUK_HSTRING_FLAG_ASCII DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */ |
| 45 | +#define DUK_HSTRING_FLAG_ARRIDX DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */ |
| 46 | +#define DUK_HSTRING_FLAG_SYMBOL DUK_HEAPHDR_USER_FLAG(2) /* string is a symbol (invalid utf-8) */ |
| 47 | +#define DUK_HSTRING_FLAG_HIDDEN \ |
| 48 | + DUK_HEAPHDR_USER_FLAG(3) /* string is a hidden symbol (implies symbol, Duktape 1.x internal string) */ |
| 49 | +#define DUK_HSTRING_FLAG_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(4) /* string is a reserved word (non-strict) */ |
| 50 | +#define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD DUK_HEAPHDR_USER_FLAG(5) /* string is a reserved word (strict) */ |
| 51 | +#define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS DUK_HEAPHDR_USER_FLAG(6) /* string is 'eval' or 'arguments' */ |
| 52 | +#define DUK_HSTRING_FLAG_EXTDATA DUK_HEAPHDR_USER_FLAG(7) /* string data is external (duk_hstring_external) */ |
| 53 | +#define DUK_HSTRING_FLAG_PINNED_LITERAL DUK_HEAPHDR_USER_FLAG(8) /* string is a literal, and pinned */ |
| 54 | + |
| 55 | +#define DUK_HSTRING_HAS_ASCII(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
| 56 | +#define DUK_HSTRING_HAS_ARRIDX(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
| 57 | +#define DUK_HSTRING_HAS_SYMBOL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
| 58 | +#define DUK_HSTRING_HAS_HIDDEN(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
| 59 | +#define DUK_HSTRING_HAS_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
| 60 | +#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
| 61 | +#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
| 62 | +#define DUK_HSTRING_HAS_EXTDATA(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
| 63 | +#define DUK_HSTRING_HAS_PINNED_LITERAL(x) DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
| 64 | + |
| 65 | +#define DUK_HSTRING_SET_ASCII(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
| 66 | +#define DUK_HSTRING_SET_ARRIDX(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
| 67 | +#define DUK_HSTRING_SET_SYMBOL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
| 68 | +#define DUK_HSTRING_SET_HIDDEN(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
| 69 | +#define DUK_HSTRING_SET_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
| 70 | +#define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
| 71 | +#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
| 72 | +#define DUK_HSTRING_SET_EXTDATA(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
| 73 | +#define DUK_HSTRING_SET_PINNED_LITERAL(x) DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
| 74 | + |
| 75 | +#define DUK_HSTRING_CLEAR_ASCII(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII) |
| 76 | +#define DUK_HSTRING_CLEAR_ARRIDX(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX) |
| 77 | +#define DUK_HSTRING_CLEAR_SYMBOL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL) |
| 78 | +#define DUK_HSTRING_CLEAR_HIDDEN(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN) |
| 79 | +#define DUK_HSTRING_CLEAR_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD) |
| 80 | +#define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD) |
| 81 | +#define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS) |
| 82 | +#define DUK_HSTRING_CLEAR_EXTDATA(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA) |
| 83 | +#define DUK_HSTRING_CLEAR_PINNED_LITERAL(x) DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_PINNED_LITERAL) |
| 84 | + |
| 85 | +#if 0 /* Slightly smaller code without explicit flag, but explicit flag \ |
| 86 | + * is very useful when 'clen' is dropped. \ |
| 87 | + */ |
| 88 | +#define DUK_HSTRING_IS_ASCII(x) (DUK_HSTRING_GET_BYTELEN((x)) == DUK_HSTRING_GET_CHARLEN((x))) |
88 | 89 | #endif |
89 | | -#define DUK_HSTRING_IS_ASCII(x) DUK_HSTRING_HAS_ASCII((x)) /* lazily set! */ |
90 | | -#define DUK_HSTRING_IS_EMPTY(x) (DUK_HSTRING_GET_BYTELEN((x)) == 0) |
| 90 | +#define DUK_HSTRING_IS_ASCII(x) DUK_HSTRING_HAS_ASCII((x)) /* lazily set! */ |
| 91 | +#define DUK_HSTRING_IS_EMPTY(x) (DUK_HSTRING_GET_BYTELEN((x)) == 0) |
91 | 92 |
|
92 | 93 | #if defined(DUK_USE_STRHASH16) |
93 | | -#define DUK_HSTRING_GET_HASH(x) ((x)->hdr.h_flags >> 16) |
94 | | -#define DUK_HSTRING_SET_HASH(x,v) do { \ |
| 94 | +#define DUK_HSTRING_GET_HASH(x) ((x)->hdr.h_flags >> 16) |
| 95 | +#define DUK_HSTRING_SET_HASH(x, v) \ |
| 96 | + do { \ |
95 | 97 | (x)->hdr.h_flags = ((x)->hdr.h_flags & 0x0000ffffUL) | ((v) << 16); \ |
96 | 98 | } while (0) |
97 | 99 | #else |
98 | | -#define DUK_HSTRING_GET_HASH(x) ((x)->hash) |
99 | | -#define DUK_HSTRING_SET_HASH(x,v) do { \ |
| 100 | +#define DUK_HSTRING_GET_HASH(x) ((x)->hash) |
| 101 | +#define DUK_HSTRING_SET_HASH(x, v) \ |
| 102 | + do { \ |
100 | 103 | (x)->hash = (v); \ |
101 | 104 | } while (0) |
102 | 105 | #endif |
103 | 106 |
|
104 | 107 | #if defined(DUK_USE_STRLEN16) |
105 | | -#define DUK_HSTRING_GET_BYTELEN(x) ((x)->hdr.h_strextra16) |
106 | | -#define DUK_HSTRING_SET_BYTELEN(x,v) do { \ |
| 108 | +#define DUK_HSTRING_GET_BYTELEN(x) ((x)->hdr.h_strextra16) |
| 109 | +#define DUK_HSTRING_SET_BYTELEN(x, v) \ |
| 110 | + do { \ |
107 | 111 | (x)->hdr.h_strextra16 = (v); \ |
108 | 112 | } while (0) |
109 | 113 | #if defined(DUK_USE_HSTRING_CLEN) |
110 | | -#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
111 | | -#define DUK_HSTRING_SET_CHARLEN(x,v) do { \ |
| 114 | +#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
| 115 | +#define DUK_HSTRING_SET_CHARLEN(x, v) \ |
| 116 | + do { \ |
112 | 117 | (x)->clen16 = (v); \ |
113 | 118 | } while (0) |
114 | 119 | #else |
115 | | -#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
116 | | -#define DUK_HSTRING_SET_CHARLEN(x,v) do { \ |
117 | | - DUK_ASSERT(0); /* should never be called */ \ |
| 120 | +#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
| 121 | +#define DUK_HSTRING_SET_CHARLEN(x, v) \ |
| 122 | + do { \ |
| 123 | + DUK_ASSERT(0); /* should never be called */ \ |
118 | 124 | } while (0) |
119 | 125 | #endif |
120 | 126 | #else |
121 | | -#define DUK_HSTRING_GET_BYTELEN(x) ((x)->blen) |
122 | | -#define DUK_HSTRING_SET_BYTELEN(x,v) do { \ |
| 127 | +#define DUK_HSTRING_GET_BYTELEN(x) ((x)->blen) |
| 128 | +#define DUK_HSTRING_SET_BYTELEN(x, v) \ |
| 129 | + do { \ |
123 | 130 | (x)->blen = (v); \ |
124 | 131 | } while (0) |
125 | | -#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
126 | | -#define DUK_HSTRING_SET_CHARLEN(x,v) do { \ |
| 132 | +#define DUK_HSTRING_GET_CHARLEN(x) duk_hstring_get_charlen((x)) |
| 133 | +#define DUK_HSTRING_SET_CHARLEN(x, v) \ |
| 134 | + do { \ |
127 | 135 | (x)->clen = (v); \ |
128 | 136 | } while (0) |
129 | 137 | #endif |
130 | 138 |
|
131 | 139 | #if defined(DUK_USE_HSTRING_EXTDATA) |
132 | | -#define DUK_HSTRING_GET_EXTDATA(x) \ |
133 | | - ((x)->extdata) |
| 140 | +#define DUK_HSTRING_GET_EXTDATA(x) ((x)->extdata) |
134 | 141 | #define DUK_HSTRING_GET_DATA(x) \ |
135 | | - (DUK_HSTRING_HAS_EXTDATA((x)) ? \ |
136 | | - DUK_HSTRING_GET_EXTDATA((const duk_hstring_external *) (x)) : ((const duk_uint8_t *) ((x) + 1))) |
| 142 | + (DUK_HSTRING_HAS_EXTDATA((x)) ? DUK_HSTRING_GET_EXTDATA((const duk_hstring_external *) (x)) : \ |
| 143 | + ((const duk_uint8_t *) ((x) + 1))) |
137 | 144 | #else |
138 | | -#define DUK_HSTRING_GET_DATA(x) \ |
139 | | - ((const duk_uint8_t *) ((x) + 1)) |
| 145 | +#define DUK_HSTRING_GET_DATA(x) ((const duk_uint8_t *) ((x) + 1)) |
140 | 146 | #endif |
141 | 147 |
|
142 | | -#define DUK_HSTRING_GET_DATA_END(x) \ |
143 | | - (DUK_HSTRING_GET_DATA((x)) + (x)->blen) |
| 148 | +#define DUK_HSTRING_GET_DATA_END(x) (DUK_HSTRING_GET_DATA((x)) + (x)->blen) |
144 | 149 |
|
145 | 150 | /* Marker value; in E5 2^32-1 is not a valid array index (2^32-2 is highest |
146 | 151 | * valid). |
147 | 152 | */ |
148 | | -#define DUK_HSTRING_NO_ARRAY_INDEX (0xffffffffUL) |
| 153 | +#define DUK_HSTRING_NO_ARRAY_INDEX (0xffffffffUL) |
149 | 154 |
|
150 | 155 | #if defined(DUK_USE_HSTRING_ARRIDX) |
151 | | -#define DUK_HSTRING_GET_ARRIDX_FAST(h) ((h)->arridx) |
152 | | -#define DUK_HSTRING_GET_ARRIDX_SLOW(h) ((h)->arridx) |
| 156 | +#define DUK_HSTRING_GET_ARRIDX_FAST(h) ((h)->arridx) |
| 157 | +#define DUK_HSTRING_GET_ARRIDX_SLOW(h) ((h)->arridx) |
153 | 158 | #else |
154 | 159 | /* Get array index related to string (or return DUK_HSTRING_NO_ARRAY_INDEX); |
155 | 160 | * avoids helper call if string has no array index value. |
156 | 161 | */ |
157 | | -#define DUK_HSTRING_GET_ARRIDX_FAST(h) \ |
| 162 | +#define DUK_HSTRING_GET_ARRIDX_FAST(h) \ |
158 | 163 | (DUK_HSTRING_HAS_ARRIDX((h)) ? duk_js_to_arrayindex_hstring_fast_known((h)) : DUK_HSTRING_NO_ARRAY_INDEX) |
159 | 164 |
|
160 | 165 | /* Slower but more compact variant. */ |
161 | | -#define DUK_HSTRING_GET_ARRIDX_SLOW(h) \ |
162 | | - (duk_js_to_arrayindex_hstring_fast((h))) |
| 166 | +#define DUK_HSTRING_GET_ARRIDX_SLOW(h) (duk_js_to_arrayindex_hstring_fast((h))) |
163 | 167 | #endif |
164 | 168 |
|
165 | 169 | /* XXX: these actually fit into duk_hstring */ |
166 | | -#define DUK_SYMBOL_TYPE_HIDDEN 0 |
167 | | -#define DUK_SYMBOL_TYPE_GLOBAL 1 |
168 | | -#define DUK_SYMBOL_TYPE_LOCAL 2 |
| 170 | +#define DUK_SYMBOL_TYPE_HIDDEN 0 |
| 171 | +#define DUK_SYMBOL_TYPE_GLOBAL 1 |
| 172 | +#define DUK_SYMBOL_TYPE_LOCAL 2 |
169 | 173 | #define DUK_SYMBOL_TYPE_WELLKNOWN 3 |
170 | 174 |
|
171 | 175 | /* Assertion for duk_hstring validity. */ |
172 | 176 | #if defined(DUK_USE_ASSERTIONS) |
173 | 177 | DUK_INTERNAL_DECL void duk_hstring_assert_valid(duk_hstring *h); |
174 | | -#define DUK_HSTRING_ASSERT_VALID(h) do { duk_hstring_assert_valid((h)); } while (0) |
| 178 | +#define DUK_HSTRING_ASSERT_VALID(h) \ |
| 179 | + do { \ |
| 180 | + duk_hstring_assert_valid((h)); \ |
| 181 | + } while (0) |
175 | 182 | #else |
176 | | -#define DUK_HSTRING_ASSERT_VALID(h) do {} while (0) |
| 183 | +#define DUK_HSTRING_ASSERT_VALID(h) \ |
| 184 | + do { \ |
| 185 | + } while (0) |
177 | 186 | #endif |
178 | 187 |
|
179 | 188 | /* |
@@ -243,11 +252,14 @@ struct duk_hstring_external { |
243 | 252 | * Prototypes |
244 | 253 | */ |
245 | 254 |
|
246 | | -DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, duk_hstring *h, duk_uint_t pos, duk_bool_t surrogate_aware); |
| 255 | +DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, |
| 256 | + duk_hstring *h, |
| 257 | + duk_uint_t pos, |
| 258 | + duk_bool_t surrogate_aware); |
247 | 259 | DUK_INTERNAL_DECL duk_bool_t duk_hstring_equals_ascii_cstring(duk_hstring *h, const char *cstr); |
248 | 260 | DUK_INTERNAL_DECL duk_size_t duk_hstring_get_charlen(duk_hstring *h); |
249 | 261 | #if !defined(DUK_USE_HSTRING_LAZY_CLEN) |
250 | 262 | DUK_INTERNAL_DECL void duk_hstring_init_charlen(duk_hstring *h); |
251 | 263 | #endif |
252 | 264 |
|
253 | | -#endif /* DUK_HSTRING_H_INCLUDED */ |
| 265 | +#endif /* DUK_HSTRING_H_INCLUDED */ |
0 commit comments