duktape 1.1.2.0 → 1.2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/duktape/duktape.c +5711 -1451
- data/ext/duktape/duktape.h +268 -23
- data/lib/duktape/version.rb +1 -1
- metadata +2 -2
data/ext/duktape/duktape.h
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
/*
|
2
|
-
* Duktape public API for Duktape 1.1.
|
2
|
+
* Duktape public API for Duktape 1.2.1.
|
3
3
|
* See the API reference for documentation on call semantics.
|
4
4
|
* The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED
|
5
5
|
* include guard. Other parts of the header are Duktape
|
6
6
|
* internal and related to platform/compiler/feature detection.
|
7
7
|
*
|
8
|
-
* Git commit
|
8
|
+
* Git commit 74bd1c845e5198b5e2d6cb7c98e54c3af1d6c0e4 (v1.2.1).
|
9
9
|
*
|
10
10
|
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
|
11
11
|
* licensing information.
|
@@ -67,6 +67,7 @@
|
|
67
67
|
* * Niki Dobrev
|
68
68
|
* * Andreas \u00d6man <andreas@lonelycoder.com>
|
69
69
|
* * L\u00e1szl\u00f3 Lang\u00f3 <llango.u-szeged@partner.samsung.com>
|
70
|
+
* * Legimet <legimet.calc@gmail.com>
|
70
71
|
*
|
71
72
|
* Other contributions
|
72
73
|
* ===================
|
@@ -94,6 +95,12 @@
|
|
94
95
|
* * David Demelier (https://github.com/hftmarkand)
|
95
96
|
* * Tim Caswell (https://github.com/creationix)
|
96
97
|
* * Mitchell Blank Jr (https://github.com/mitchblank)
|
98
|
+
* * https://github.com/yushli
|
99
|
+
* * Seo Sanghyeon (https://github.com/sanxiyn)
|
100
|
+
* * Han ChoongWoo (https://github.com/tunz)
|
101
|
+
* * Joshua Peek (https://github.com/josh)
|
102
|
+
* * Bruce E. Pascoe (https://github.com/fatcerberus)
|
103
|
+
* * https://github.com/Kelledin
|
97
104
|
*
|
98
105
|
* If you are accidentally missing from this list, send me an e-mail
|
99
106
|
* (``sami.vaarala@iki.fi``) and I'll fix the omission.
|
@@ -241,13 +248,19 @@ static __inline__ unsigned long long duk_rdtsc(void) {
|
|
241
248
|
#endif
|
242
249
|
|
243
250
|
/* MIPS */
|
244
|
-
/*
|
251
|
+
/* Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */
|
245
252
|
#if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \
|
246
253
|
defined(_R3000) || defined(_R4000) || defined(_R5900) || \
|
247
254
|
defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \
|
248
255
|
defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \
|
249
256
|
defined(__mips) || defined(__MIPS__)
|
250
257
|
#define DUK_F_MIPS
|
258
|
+
#if defined(__LP64__) || defined(__mips64) || defined(__mips64__) || \
|
259
|
+
defined(__mips_n64)
|
260
|
+
#define DUK_F_MIPS64
|
261
|
+
#else
|
262
|
+
#define DUK_F_MIPS32
|
263
|
+
#endif
|
251
264
|
#endif
|
252
265
|
|
253
266
|
/* SuperH */
|
@@ -310,6 +323,10 @@ static __inline__ unsigned long long duk_rdtsc(void) {
|
|
310
323
|
#define DUK_F_WINDOWS
|
311
324
|
#endif
|
312
325
|
|
326
|
+
#if defined(__APPLE__)
|
327
|
+
#define DUK_F_APPLE
|
328
|
+
#endif
|
329
|
+
|
313
330
|
/* Atari ST TOS. __TOS__ defined by PureC (which doesn't work as a target now
|
314
331
|
* because int is 16-bit, to be fixed). No platform define in VBCC apparently,
|
315
332
|
* so to use with VBCC, user must define '__TOS__' manually.
|
@@ -340,6 +357,11 @@ static __inline__ unsigned long long duk_rdtsc(void) {
|
|
340
357
|
#define DUK_F_QNX
|
341
358
|
#endif
|
342
359
|
|
360
|
+
/* TI-Nspire (using Ndless) */
|
361
|
+
#if defined(_TINSPIRE)
|
362
|
+
#define DUK_F_TINSPIRE
|
363
|
+
#endif
|
364
|
+
|
343
365
|
/* GCC and GCC version convenience define. */
|
344
366
|
#if defined(__GNUC__)
|
345
367
|
#define DUK_F_GCC
|
@@ -506,6 +528,7 @@ static __inline__ unsigned long long duk_rdtsc(void) {
|
|
506
528
|
#define DUK_USE_DATE_TZO_GMTIME_R
|
507
529
|
#define DUK_USE_DATE_PRS_STRPTIME
|
508
530
|
#define DUK_USE_DATE_FMT_STRFTIME
|
531
|
+
#include <TargetConditionals.h>
|
509
532
|
#include <architecture/byte_order.h>
|
510
533
|
#include <limits.h>
|
511
534
|
#include <sys/param.h>
|
@@ -587,6 +610,16 @@ static __inline__ unsigned long long duk_rdtsc(void) {
|
|
587
610
|
#include <sys/param.h>
|
588
611
|
#include <sys/time.h>
|
589
612
|
#include <time.h>
|
613
|
+
#elif defined(DUK_F_TINSPIRE)
|
614
|
+
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
|
615
|
+
#define DUK_USE_DATE_TZO_GMTIME_R
|
616
|
+
#define DUK_USE_DATE_PRS_STRPTIME
|
617
|
+
#define DUK_USE_DATE_FMT_STRFTIME
|
618
|
+
#include <sys/types.h>
|
619
|
+
#include <limits.h>
|
620
|
+
#include <sys/param.h>
|
621
|
+
#include <sys/time.h>
|
622
|
+
#include <time.h>
|
590
623
|
#elif defined(DUK_F_LINUX)
|
591
624
|
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
|
592
625
|
#define DUK_USE_DATE_TZO_GMTIME_R
|
@@ -929,7 +962,7 @@ typedef signed long long duk_int64_t;
|
|
929
962
|
typedef unsigned long duk_uint64_t;
|
930
963
|
typedef signed long duk_int64_t;
|
931
964
|
#endif
|
932
|
-
#if !defined(
|
965
|
+
#if !defined(DUK_F_HAVE_64BIT)
|
933
966
|
/* cannot detect 64-bit type, not always needed so don't error */
|
934
967
|
#endif
|
935
968
|
|
@@ -1247,11 +1280,17 @@ typedef double duk_double_t;
|
|
1247
1280
|
#define DUK_USE_ALIGN_8
|
1248
1281
|
#elif defined(DUK_F_ARM)
|
1249
1282
|
#define DUK_USE_ALIGN_4
|
1250
|
-
#elif defined(
|
1283
|
+
#elif defined(DUK_F_MIPS32)
|
1251
1284
|
/* Based on 'make checkalign' there are no alignment requirements on
|
1252
|
-
* Linux MIPS except for doubles, which need align by 4.
|
1285
|
+
* Linux MIPS except for doubles, which need align by 4. Alignment
|
1286
|
+
* requirements vary based on target though.
|
1253
1287
|
*/
|
1254
1288
|
#define DUK_USE_ALIGN_4
|
1289
|
+
#elif defined(DUK_F_MIPS64)
|
1290
|
+
/* Good default is a bit arbitrary because alignment requirements
|
1291
|
+
* depend on target. See https://github.com/svaarala/duktape/issues/102.
|
1292
|
+
*/
|
1293
|
+
#define DUK_USE_ALIGN_8
|
1255
1294
|
#elif defined(DUK_F_SUPERH)
|
1256
1295
|
/* Based on 'make checkalign' there are no alignment requirements on
|
1257
1296
|
* Linux SH4, but align by 4 is probably a good basic default.
|
@@ -2054,19 +2093,29 @@ typedef FILE duk_file;
|
|
2054
2093
|
#endif
|
2055
2094
|
|
2056
2095
|
/*
|
2057
|
-
*
|
2096
|
+
* Function inlining control
|
2097
|
+
*
|
2098
|
+
* DUK_NOINLINE: avoid inlining a function.
|
2099
|
+
* DUK_INLINE: suggest inlining a function.
|
2100
|
+
* DUK_ALWAYS_INLINE: force inlining for critical functions.
|
2058
2101
|
*/
|
2059
2102
|
|
2060
2103
|
#if defined(DUK_F_CLANG)
|
2061
|
-
#define DUK_NOINLINE
|
2104
|
+
#define DUK_NOINLINE __attribute__((noinline))
|
2105
|
+
#define DUK_INLINE inline
|
2106
|
+
#define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
|
2062
2107
|
#elif defined(DUK_F_GCC) && defined(DUK_F_GCC_VERSION)
|
2063
2108
|
#if (DUK_F_GCC_VERSION >= 30101)
|
2064
|
-
#define DUK_NOINLINE
|
2109
|
+
#define DUK_NOINLINE __attribute__((noinline))
|
2110
|
+
#define DUK_INLINE inline
|
2111
|
+
#define DUK_ALWAYS_INLINE inline __attribute__((always_inline))
|
2065
2112
|
#endif
|
2066
2113
|
#endif
|
2067
2114
|
|
2068
2115
|
#if !defined(DUK_NOINLINE)
|
2069
|
-
#define DUK_NOINLINE
|
2116
|
+
#define DUK_NOINLINE /*nop*/
|
2117
|
+
#define DUK_INLINE /*nop*/
|
2118
|
+
#define DUK_ALWAYS_INLINE /*nop*/
|
2070
2119
|
#endif
|
2071
2120
|
|
2072
2121
|
/*
|
@@ -2168,6 +2217,23 @@ typedef FILE duk_file;
|
|
2168
2217
|
#define DUK_FUNC_MACRO "unknown"
|
2169
2218
|
#endif
|
2170
2219
|
|
2220
|
+
/*
|
2221
|
+
* Byteswap macros
|
2222
|
+
*
|
2223
|
+
* These are here so that inline assembly or other platform functions can be
|
2224
|
+
* used if available.
|
2225
|
+
*/
|
2226
|
+
|
2227
|
+
#define DUK_BSWAP32(x) \
|
2228
|
+
((((duk_uint32_t) (x)) >> 24) | \
|
2229
|
+
((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \
|
2230
|
+
((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \
|
2231
|
+
(((duk_uint32_t) (x)) << 24))
|
2232
|
+
|
2233
|
+
#define DUK_BSWAP16(x) \
|
2234
|
+
((duk_uint16_t) (x) >> 8) | \
|
2235
|
+
((duk_uint16_t) (x) << 8)
|
2236
|
+
|
2171
2237
|
/*
|
2172
2238
|
* Architecture string, human readable value exposed in Duktape.env
|
2173
2239
|
*/
|
@@ -2180,8 +2246,10 @@ typedef FILE duk_file;
|
|
2180
2246
|
#define DUK_USE_ARCH_STRING "x64"
|
2181
2247
|
#elif defined(DUK_F_ARM)
|
2182
2248
|
#define DUK_USE_ARCH_STRING "arm"
|
2183
|
-
#elif defined(
|
2184
|
-
#define DUK_USE_ARCH_STRING "
|
2249
|
+
#elif defined(DUK_F_MIPS32)
|
2250
|
+
#define DUK_USE_ARCH_STRING "mips32"
|
2251
|
+
#elif defined(DUK_F_MIPS64)
|
2252
|
+
#define DUK_USE_ARCH_STRING "mips64"
|
2185
2253
|
#elif defined(DUK_F_SUPERH)
|
2186
2254
|
#define DUK_USE_ARCH_STRING "sh"
|
2187
2255
|
#elif defined(DUK_F_M68K)
|
@@ -2200,6 +2268,17 @@ typedef FILE duk_file;
|
|
2200
2268
|
|
2201
2269
|
#if defined(DUK_F_LINUX)
|
2202
2270
|
#define DUK_USE_OS_STRING "linux"
|
2271
|
+
#elif defined(__APPLE__)
|
2272
|
+
/* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */
|
2273
|
+
#if TARGET_IPHONE_SIMULATOR
|
2274
|
+
#define DUK_USE_OS_STRING "iphone-sim"
|
2275
|
+
#elif TARGET_OS_IPHONE
|
2276
|
+
#define DUK_USE_OS_STRING "iphone"
|
2277
|
+
#elif TARGET_OS_MAC
|
2278
|
+
#define DUK_USE_OS_STRING "ios"
|
2279
|
+
#else
|
2280
|
+
#define DUK_USE_OS_STRING "ios-unknown"
|
2281
|
+
#endif
|
2203
2282
|
#elif defined(DUK_F_FREEBSD)
|
2204
2283
|
#define DUK_USE_OS_STRING "freebsd"
|
2205
2284
|
#elif defined(DUK_F_OPENBSD)
|
@@ -2218,6 +2297,8 @@ typedef FILE duk_file;
|
|
2218
2297
|
#define DUK_USE_OS_STRING "amigaos"
|
2219
2298
|
#elif defined(DUK_F_QNX)
|
2220
2299
|
#define DUK_USE_OS_STRING "qnx"
|
2300
|
+
#elif defined(DUK_F_TINSPIRE)
|
2301
|
+
#define DUK_USE_OS_STRING "tinspire"
|
2221
2302
|
#else
|
2222
2303
|
#define DUK_USE_OS_STRING "unknown"
|
2223
2304
|
#endif
|
@@ -2280,16 +2361,56 @@ typedef FILE duk_file;
|
|
2280
2361
|
#error internal error
|
2281
2362
|
#endif
|
2282
2363
|
|
2364
|
+
/*
|
2365
|
+
* Target info string
|
2366
|
+
*/
|
2367
|
+
|
2368
|
+
#if defined(DUK_OPT_TARGET_INFO)
|
2369
|
+
#define DUK_USE_TARGET_INFO DUK_OPT_TARGET_INFO
|
2370
|
+
#else
|
2371
|
+
#define DUK_USE_TARGET_INFO "unknown"
|
2372
|
+
#endif
|
2373
|
+
|
2374
|
+
/*
|
2375
|
+
* Speed/size and other performance options
|
2376
|
+
*/
|
2377
|
+
|
2378
|
+
/* Use fast ("inline") refcount operations instead of calling out to helpers
|
2379
|
+
* by default. The difference in binary size is small (~1kB on x64).
|
2380
|
+
*/
|
2381
|
+
#define DUK_USE_FAST_REFCOUNT_DEFAULT
|
2382
|
+
|
2383
|
+
/* Assert for valstack space but don't check for it in non-assert build.
|
2384
|
+
* Valstack overruns (writing beyond checked space) is memory unsafe and
|
2385
|
+
* potentially a segfault. Produces a smaller and faster binary.
|
2386
|
+
* (In practice the speed difference is small with -O3 so default to
|
2387
|
+
* safer behavior for now.)
|
2388
|
+
*/
|
2389
|
+
#undef DUK_USE_VALSTACK_UNSAFE
|
2390
|
+
|
2391
|
+
/* Catch-all flag which can be used to choose between variant algorithms
|
2392
|
+
* where a speed-size tradeoff exists (e.g. lookup tables). When it really
|
2393
|
+
* matters, specific use flags may be appropriate.
|
2394
|
+
*/
|
2395
|
+
#define DUK_USE_PREFER_SIZE
|
2396
|
+
|
2283
2397
|
/*
|
2284
2398
|
* Tagged type representation (duk_tval)
|
2285
2399
|
*/
|
2286
2400
|
|
2287
2401
|
#undef DUK_USE_PACKED_TVAL
|
2288
|
-
#undef DUK_USE_FULL_TVAL
|
2289
2402
|
|
2290
2403
|
#if defined(DUK_USE_PACKED_TVAL_POSSIBLE) && !defined(DUK_OPT_NO_PACKED_TVAL)
|
2291
2404
|
#define DUK_USE_PACKED_TVAL
|
2292
|
-
#
|
2405
|
+
#endif
|
2406
|
+
|
2407
|
+
/* Support for 48-bit signed integer duk_tval with transparent semantics. */
|
2408
|
+
#undef DUK_USE_FASTINT
|
2409
|
+
#if defined(DUK_OPT_FASTINT)
|
2410
|
+
#if !defined(DUK_F_HAVE_64BIT)
|
2411
|
+
#error DUK_OPT_FASTINT requires 64-bit integer type support at the moment
|
2412
|
+
#endif
|
2413
|
+
#define DUK_USE_FASTINT
|
2293
2414
|
#endif
|
2294
2415
|
|
2295
2416
|
/*
|
@@ -2300,7 +2421,6 @@ typedef FILE duk_file;
|
|
2300
2421
|
#define DUK_USE_DOUBLE_LINKED_HEAP
|
2301
2422
|
#define DUK_USE_MARK_AND_SWEEP
|
2302
2423
|
#define DUK_USE_MS_STRINGTABLE_RESIZE
|
2303
|
-
#undef DUK_USE_GC_TORTURE
|
2304
2424
|
|
2305
2425
|
#if defined(DUK_OPT_NO_REFERENCE_COUNTING)
|
2306
2426
|
#undef DUK_USE_REFERENCE_COUNTING
|
@@ -2329,6 +2449,7 @@ typedef FILE duk_file;
|
|
2329
2449
|
#undef DUK_USE_MS_STRINGTABLE_RESIZE
|
2330
2450
|
#endif
|
2331
2451
|
|
2452
|
+
#undef DUK_USE_GC_TORTURE
|
2332
2453
|
#if defined(DUK_OPT_GC_TORTURE)
|
2333
2454
|
#define DUK_USE_GC_TORTURE
|
2334
2455
|
#endif
|
@@ -2387,15 +2508,44 @@ typedef FILE duk_file;
|
|
2387
2508
|
* Execution and debugger options
|
2388
2509
|
*/
|
2389
2510
|
|
2390
|
-
/* Executor interrupt disabled for 1.0 release: there is no API to use it */
|
2391
|
-
#if 0
|
2392
|
-
#define DUK_USE_INTERRUPT_COUNTER
|
2393
|
-
#if defined(DUK_OPT_NO_INTERRUPT_COUNTER)
|
2394
2511
|
#undef DUK_USE_INTERRUPT_COUNTER
|
2512
|
+
#if defined(DUK_OPT_INTERRUPT_COUNTER)
|
2513
|
+
#define DUK_USE_INTERRUPT_COUNTER
|
2514
|
+
#endif
|
2515
|
+
|
2516
|
+
#undef DUK_USE_EXEC_TIMEOUT_CHECK
|
2517
|
+
#if defined(DUK_OPT_EXEC_TIMEOUT_CHECK)
|
2518
|
+
#define DUK_USE_EXEC_TIMEOUT_CHECK(udata) DUK_OPT_EXEC_TIMEOUT_CHECK((udata))
|
2395
2519
|
#endif
|
2520
|
+
|
2521
|
+
#undef DUK_USE_DEBUGGER_SUPPORT
|
2522
|
+
#if defined(DUK_OPT_DEBUGGER_SUPPORT)
|
2523
|
+
#define DUK_USE_DEBUGGER_SUPPORT
|
2396
2524
|
#endif
|
2397
2525
|
|
2398
|
-
#undef
|
2526
|
+
#undef DUK_USE_DEBUGGER_FWD_PRINTALERT
|
2527
|
+
#if defined(DUK_OPT_DEBUGGER_SUPPORT) && defined(DUK_OPT_DEBUGGER_FWD_PRINTALERT)
|
2528
|
+
#define DUK_USE_DEBUGGER_FWD_PRINTALERT
|
2529
|
+
#endif
|
2530
|
+
|
2531
|
+
#undef DUK_USE_DEBUGGER_FWD_LOGGING
|
2532
|
+
#if defined(DUK_OPT_DEBUGGER_SUPPORT) && defined(DUK_OPT_DEBUGGER_FWD_LOGGING)
|
2533
|
+
#define DUK_USE_DEBUGGER_FWD_LOGGING
|
2534
|
+
#endif
|
2535
|
+
|
2536
|
+
/* DumpHeap is optional because it's not always needed and has a relatively
|
2537
|
+
* large footprint.
|
2538
|
+
*/
|
2539
|
+
#undef DUK_USE_DEBUGGER_DUMPHEAP
|
2540
|
+
#if defined(DUK_OPT_DEBUGGER_DUMPHEAP)
|
2541
|
+
#define DUK_USE_DEBUGGER_DUMPHEAP
|
2542
|
+
#endif
|
2543
|
+
|
2544
|
+
/* Debugger transport read/write torture. */
|
2545
|
+
#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE
|
2546
|
+
#if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE)
|
2547
|
+
#define DUK_USE_DEBUGGER_TRANSPORT_TORTURE
|
2548
|
+
#endif
|
2399
2549
|
|
2400
2550
|
/* For opcodes with indirect indices, check final index against stack size.
|
2401
2551
|
* This should not be necessary because the compiler is trusted, and we don't
|
@@ -2616,6 +2766,15 @@ typedef FILE duk_file;
|
|
2616
2766
|
#undef DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
|
2617
2767
|
#endif
|
2618
2768
|
|
2769
|
+
/* Non-standard array fast path write behavior: when writing to numeric
|
2770
|
+
* indexes of an Array instance, assume Array.prototype doesn't have
|
2771
|
+
* conflicting properties (e.g. a non-writable property "7").
|
2772
|
+
*/
|
2773
|
+
#define DUK_USE_NONSTD_ARRAY_WRITE
|
2774
|
+
#if defined(DUK_OPT_NO_NONSTD_ARRAY_WRITE)
|
2775
|
+
#undef DUK_USE_NONSTD_ARRAY_WRITE
|
2776
|
+
#endif
|
2777
|
+
|
2619
2778
|
/*
|
2620
2779
|
* Tailcalls
|
2621
2780
|
*/
|
@@ -2980,6 +3139,12 @@ typedef void (*duk_fatal_function) (duk_context *ctx, duk_errcode_t code, const
|
|
2980
3139
|
typedef void (*duk_decode_char_function) (void *udata, duk_codepoint_t codepoint);
|
2981
3140
|
typedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t codepoint);
|
2982
3141
|
typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx);
|
3142
|
+
typedef duk_size_t (*duk_debug_read_function) (void *udata, char *buffer, duk_size_t length);
|
3143
|
+
typedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length);
|
3144
|
+
typedef duk_size_t (*duk_debug_peek_function) (void *udata);
|
3145
|
+
typedef void (*duk_debug_read_flush_function) (void *udata);
|
3146
|
+
typedef void (*duk_debug_write_flush_function) (void *udata);
|
3147
|
+
typedef void (*duk_debug_detached_function) (void *udata);
|
2983
3148
|
|
2984
3149
|
struct duk_memory_functions {
|
2985
3150
|
duk_alloc_function alloc_func;
|
@@ -3009,13 +3174,16 @@ struct duk_number_list_entry {
|
|
3009
3174
|
* have 99 for patch level (e.g. 0.10.99 would be a development version
|
3010
3175
|
* after 0.10.0 but before the next official release).
|
3011
3176
|
*/
|
3012
|
-
#define DUK_VERSION
|
3177
|
+
#define DUK_VERSION 10201L
|
3013
3178
|
|
3014
3179
|
/* Git describe for Duktape build. Useful for non-official snapshot builds
|
3015
3180
|
* so that application code can easily log which Duktape snapshot was used.
|
3016
3181
|
* Not available in the Ecmascript environment.
|
3017
3182
|
*/
|
3018
|
-
#define DUK_GIT_DESCRIBE "v1.1
|
3183
|
+
#define DUK_GIT_DESCRIBE "v1.2.1"
|
3184
|
+
|
3185
|
+
/* Duktape debug protocol version used by this build. */
|
3186
|
+
#define DUK_DEBUG_PROTOCOL_VERSION 1
|
3019
3187
|
|
3020
3188
|
/* Used to represent invalid index; if caller uses this without checking,
|
3021
3189
|
* this index will map to a non-existent stack entry. Also used in some
|
@@ -3333,7 +3501,10 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_e
|
|
3333
3501
|
#define duk_push_error_object_va(ctx,err_code,fmt,ap) \
|
3334
3502
|
duk_push_error_object_va_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
|
3335
3503
|
|
3336
|
-
|
3504
|
+
#define DUK_BUF_FLAG_DYNAMIC (1 << 0) /* internal flag: dynamic buffer */
|
3505
|
+
#define DUK_BUF_FLAG_NOZERO (1 << 1) /* internal flag: don't zero allocated buffer */
|
3506
|
+
|
3507
|
+
DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);
|
3337
3508
|
|
3338
3509
|
#define duk_push_buffer(ctx,size,dynamic) \
|
3339
3510
|
duk_push_buffer_raw((ctx), (size), (dynamic));
|
@@ -3785,6 +3956,21 @@ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
|
|
3785
3956
|
#define duk_dump_context_stderr(ctx) ((void) 0)
|
3786
3957
|
#endif /* DUK_USE_FILE_IO */
|
3787
3958
|
|
3959
|
+
/*
|
3960
|
+
* Debugger (debug protocol)
|
3961
|
+
*/
|
3962
|
+
|
3963
|
+
DUK_EXTERNAL_DECL void duk_debugger_attach(duk_context *ctx,
|
3964
|
+
duk_debug_read_function read_cb,
|
3965
|
+
duk_debug_write_function write_cb,
|
3966
|
+
duk_debug_peek_function peek_cb,
|
3967
|
+
duk_debug_read_flush_function read_flush_cb,
|
3968
|
+
duk_debug_write_flush_function write_flush_cb,
|
3969
|
+
duk_debug_detached_function detached_cb,
|
3970
|
+
void *udata);
|
3971
|
+
DUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);
|
3972
|
+
DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);
|
3973
|
+
|
3788
3974
|
/*
|
3789
3975
|
* C++ name mangling
|
3790
3976
|
*/
|
@@ -3867,6 +4053,19 @@ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
|
|
3867
4053
|
#error debug printing cannot currently be used with heap pointer compression
|
3868
4054
|
#endif
|
3869
4055
|
|
4056
|
+
/*
|
4057
|
+
* Debugger consistency
|
4058
|
+
*/
|
4059
|
+
|
4060
|
+
#if defined(DUK_USE_DEBUGGER_SUPPORT)
|
4061
|
+
#if !defined(DUK_USE_INTERRUPT_COUNTER)
|
4062
|
+
#error DUK_USE_INTERRUPT_COUNTER is needed when debugger support is enabled
|
4063
|
+
#endif
|
4064
|
+
#if !defined(DUK_USE_PC2LINE)
|
4065
|
+
#error DUK_USE_PC2LINE is needed when debugger support is enabled
|
4066
|
+
#endif
|
4067
|
+
#endif
|
4068
|
+
|
3870
4069
|
/*
|
3871
4070
|
* Garbage collection consistency
|
3872
4071
|
*/
|
@@ -4076,6 +4275,25 @@ typedef union duk_double_union duk_double_union;
|
|
4076
4275
|
#define DUK_DBLUNION_GET_HIGH32(u) ((u)->ui[DUK_DBL_IDX_UI0])
|
4077
4276
|
#define DUK_DBLUNION_GET_LOW32(u) ((u)->ui[DUK_DBL_IDX_UI1])
|
4078
4277
|
|
4278
|
+
#ifdef DUK_USE_64BIT_OPS
|
4279
|
+
#ifdef DUK_USE_DOUBLE_ME
|
4280
|
+
#define DUK_DBLUNION_SET_UINT64(u,v) do { \
|
4281
|
+
(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) ((v) >> 32); \
|
4282
|
+
(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \
|
4283
|
+
} while (0)
|
4284
|
+
#define DUK_DBLUNION_GET_UINT64(u) \
|
4285
|
+
((((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI0]) << 32) | \
|
4286
|
+
((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI1]))
|
4287
|
+
#else
|
4288
|
+
#define DUK_DBLUNION_SET_UINT64(u,v) do { \
|
4289
|
+
(u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \
|
4290
|
+
} while (0)
|
4291
|
+
#define DUK_DBLUNION_GET_UINT64(u) ((u)->ull[DUK_DBL_IDX_ULL0])
|
4292
|
+
#endif
|
4293
|
+
#define DUK_DBLUNION_SET_INT64(u,v) DUK_DBLUNION_SET_UINT64((u), (duk_uint64_t) (v))
|
4294
|
+
#define DUK_DBLUNION_GET_INT64(u) ((duk_int64_t) DUK_DBLUNION_GET_UINT64((u)))
|
4295
|
+
#endif /* DUK_USE_64BIT_OPS */
|
4296
|
+
|
4079
4297
|
/*
|
4080
4298
|
* Double NaN manipulation macros related to NaN normalization needed when
|
4081
4299
|
* using the packed duk_tval representation. NaN normalization is necessary
|
@@ -4209,6 +4427,33 @@ typedef union duk_double_union duk_double_union;
|
|
4209
4427
|
} while (0)
|
4210
4428
|
#endif /* DUK_USE_PACKED_TVAL */
|
4211
4429
|
|
4430
|
+
/* Byteswap an (aligned) duk_double_union. */
|
4431
|
+
#if defined(DUK_USE_DOUBLE_LE)
|
4432
|
+
#define DUK_DBLUNION_BSWAP(u) do { \
|
4433
|
+
duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \
|
4434
|
+
duk__bswaptmp1 = (u)->ui[0]; \
|
4435
|
+
duk__bswaptmp2 = (u)->ui[1]; \
|
4436
|
+
duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \
|
4437
|
+
duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \
|
4438
|
+
(u)->ui[0] = duk__bswaptmp2; \
|
4439
|
+
(u)->ui[1] = duk__bswaptmp1; \
|
4440
|
+
} while (0)
|
4441
|
+
#elif defined(DUK_USE_DOUBLE_ME)
|
4442
|
+
#define DUK_DBLUNION_BSWAP(u) do { \
|
4443
|
+
duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \
|
4444
|
+
duk__bswaptmp1 = (u)->ui[0]; \
|
4445
|
+
duk__bswaptmp2 = (u)->ui[1]; \
|
4446
|
+
duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \
|
4447
|
+
duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \
|
4448
|
+
(u)->ui[0] = duk__bswaptmp1; \
|
4449
|
+
(u)->ui[1] = duk__bswaptmp2; \
|
4450
|
+
} while (0)
|
4451
|
+
#elif defined(DUK_USE_DOUBLE_BE)
|
4452
|
+
#define DUK_DBLUNION_BSWAP(u) do { } while (0)
|
4453
|
+
#else
|
4454
|
+
#error internal error, double endianness insane
|
4455
|
+
#endif
|
4456
|
+
|
4212
4457
|
#endif /* DUK_DBLUNION_H_INCLUDED */
|
4213
4458
|
|
4214
4459
|
#endif /* DUKTAPE_H_INCLUDED */
|