duktape 1.0.2.0 → 1.1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /*
2
- * Duktape public API for Duktape 1.0.2.
2
+ * Duktape public API for Duktape 1.1.2.
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 a476318bf025137c2847c808a8334d8b7db985f2 (v1.0.2).
8
+ * Git commit eb523a027d3d9658a0c0e2150b29e6d87f81860c (v1.1.2).
9
9
  *
10
10
  * See Duktape AUTHORS.rst and LICENSE.txt for copyright and
11
11
  * licensing information.
@@ -19,7 +19,7 @@
19
19
  *
20
20
  * (http://opensource.org/licenses/MIT)
21
21
  *
22
- * Copyright (c) 2013-2014 by Duktape authors (see AUTHORS.rst)
22
+ * Copyright (c) 2013-2015 by Duktape authors (see AUTHORS.rst)
23
23
  *
24
24
  * Permission is hereby granted, free of charge, to any person obtaining a copy
25
25
  * of this software and associated documentation files (the "Software"), to deal
@@ -66,12 +66,13 @@
66
66
  * * Sami Vaarala <sami.vaarala@iki.fi>
67
67
  * * Niki Dobrev
68
68
  * * Andreas \u00d6man <andreas@lonelycoder.com>
69
+ * * L\u00e1szl\u00f3 Lang\u00f3 <llango.u-szeged@partner.samsung.com>
69
70
  *
70
71
  * Other contributions
71
72
  * ===================
72
73
  *
73
74
  * The following people have contributed something other than code (e.g. reported
74
- * bugs, provided ideas, etc; in order of appearance):
75
+ * bugs, provided ideas, etc; roughly in order of appearance):
75
76
  *
76
77
  * * Greg Burns
77
78
  * * Anthony Rabine
@@ -87,8 +88,15 @@
87
88
  * * Rajaran Gaunker (https://github.com/zimbabao)
88
89
  * * Andreas \u00d6man
89
90
  * * Doug Sanden
91
+ * * Josh Engebretson (https://github.com/JoshEngebretson)
90
92
  * * Remo Eichenberger (https://github.com/remoe)
91
- * * David Demelier
93
+ * * Mamod Mehyar (https://github.com/mamod)
94
+ * * David Demelier (https://github.com/hftmarkand)
95
+ * * Tim Caswell (https://github.com/creationix)
96
+ * * Mitchell Blank Jr (https://github.com/mitchblank)
97
+ *
98
+ * If you are accidentally missing from this list, send me an e-mail
99
+ * (``sami.vaarala@iki.fi``) and I'll fix the omission.
92
100
  */
93
101
 
94
102
  #ifndef DUKTAPE_H_INCLUDED
@@ -242,6 +250,16 @@ static __inline__ unsigned long long duk_rdtsc(void) {
242
250
  #define DUK_F_MIPS
243
251
  #endif
244
252
 
253
+ /* SuperH */
254
+ #if defined(__sh__) || \
255
+ defined(__sh1__) || defined(__SH1__) || \
256
+ defined(__sh2__) || defined(__SH2__) || \
257
+ defined(__sh3__) || defined(__SH3__) || \
258
+ defined(__sh4__) || defined(__SH4__) || \
259
+ defined(__sh5__) || defined(__SH5__)
260
+ #define DUK_F_SUPERH
261
+ #endif
262
+
245
263
  /* Motorola 68K. Not defined by VBCC, so user must define one of these
246
264
  * manually when using VBCC.
247
265
  */
@@ -363,6 +381,7 @@ static __inline__ unsigned long long duk_rdtsc(void) {
363
381
 
364
382
  /* MinGW */
365
383
  #if defined(__MINGW32__) || defined(__MINGW64__)
384
+ /* NOTE: Also GCC flags are detected (DUK_F_GCC etc). */
366
385
  #define DUK_F_MINGW
367
386
  #endif
368
387
 
@@ -471,6 +490,16 @@ static __inline__ unsigned long long duk_rdtsc(void) {
471
490
  #define DUK_F_NO_STDINT_H
472
491
  #endif
473
492
 
493
+ /* Workaround for older C++ compilers before including <inttypes.h>,
494
+ * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366
495
+ */
496
+ #if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
497
+ #define __STDC_LIMIT_MACROS
498
+ #endif
499
+ #if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
500
+ #define __STDC_CONSTANT_MACROS
501
+ #endif
502
+
474
503
  #if defined(__APPLE__)
475
504
  /* Mac OSX, iPhone, Darwin */
476
505
  #define DUK_USE_DATE_NOW_GETTIMEOFDAY
@@ -624,7 +653,9 @@ static __inline__ unsigned long long duk_rdtsc(void) {
624
653
  #if defined(DUK_F_NO_STDINT_H)
625
654
  /* stdint.h not available */
626
655
  #else
627
- /* technically C99 (C++11) but found in many systems */
656
+ /* Technically C99 (C++11) but found in many systems. Note the workaround
657
+ * above for some C++ compilers (__STDC_LIMIT_MACROS etc).
658
+ */
628
659
  #include <stdint.h>
629
660
  #endif
630
661
  #include <math.h>
@@ -710,7 +741,8 @@ static __inline__ unsigned long long duk_rdtsc(void) {
710
741
  * through automatic detection.
711
742
  */
712
743
  #if defined(DUK_F_HAVE_INTTYPES)
713
- /* C99 */
744
+ /* C99 or compatible */
745
+
714
746
  #define DUK_F_HAVE_64BIT
715
747
  #include <inttypes.h>
716
748
 
@@ -1162,10 +1194,11 @@ typedef double duk_double_t;
1162
1194
  #error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX
1163
1195
  #elif !defined(DUK_SIZE_MAX_COMPUTED)
1164
1196
  #if DUK_SIZE_MAX < 0xffffffffUL
1165
- /* XXX: compare against a lower value; can SIZE_MAX realistically be
1166
- * e.g. 0x7fffffffUL on a 32-bit system?
1197
+ /* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value
1198
+ * which seems incorrect if size_t is (at least) an unsigned 32-bit type.
1199
+ * However, it doesn't seem useful to error out compilation if this is the
1200
+ * case.
1167
1201
  */
1168
- #error size_t is too small
1169
1202
  #endif
1170
1203
  #endif
1171
1204
 
@@ -1215,12 +1248,23 @@ typedef double duk_double_t;
1215
1248
  #elif defined(DUK_F_ARM)
1216
1249
  #define DUK_USE_ALIGN_4
1217
1250
  #elif defined(DUK_F_MIPS)
1251
+ /* Based on 'make checkalign' there are no alignment requirements on
1252
+ * Linux MIPS except for doubles, which need align by 4.
1253
+ */
1254
+ #define DUK_USE_ALIGN_4
1255
+ #elif defined(DUK_F_SUPERH)
1256
+ /* Based on 'make checkalign' there are no alignment requirements on
1257
+ * Linux SH4, but align by 4 is probably a good basic default.
1258
+ */
1218
1259
  #define DUK_USE_ALIGN_4
1219
1260
  #elif defined(DUK_F_X86) || defined(DUK_F_X32) || defined(DUK_F_X64) || \
1220
1261
  defined(DUK_F_BCC)
1262
+ /* XXX: This is technically not guaranteed because it's possible to configure
1263
+ * an x86 to require aligned accesses with Alignment Check (AC) flag.
1264
+ */
1221
1265
  #define DUK_USE_UNALIGNED_ACCESSES_POSSIBLE
1222
1266
  #else
1223
- /* unknown, use safe default */
1267
+ /* Unknown, use safe default */
1224
1268
  #define DUK_USE_ALIGN_8
1225
1269
  #endif
1226
1270
 
@@ -1871,8 +1915,6 @@ typedef FILE duk_file;
1871
1915
 
1872
1916
  #define DUK_ABORT abort
1873
1917
  #define DUK_EXIT exit
1874
- #define DUK_SETJMP setjmp
1875
- #define DUK_LONGJMP longjmp
1876
1918
 
1877
1919
  /*
1878
1920
  * Macro hackery to convert e.g. __LINE__ to a string without formatting,
@@ -1891,7 +1933,7 @@ typedef FILE duk_file;
1891
1933
  */
1892
1934
 
1893
1935
  #define DUK_CAUSE_SEGFAULT() do { \
1894
- *((duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; \
1936
+ *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; \
1895
1937
  } while (0)
1896
1938
 
1897
1939
  /*
@@ -1992,7 +2034,7 @@ typedef FILE duk_file;
1992
2034
  #endif
1993
2035
 
1994
2036
  #if defined(DUK_USE_BRANCH_HINTS)
1995
- #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERISON >= 40500L)
2037
+ #if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
1996
2038
  /* GCC: test not very accurate; enable only in relatively recent builds
1997
2039
  * because of bugs in gcc-4.4 (http://lists.debian.org/debian-gcc/2010/04/msg00000.html)
1998
2040
  */
@@ -2011,16 +2053,45 @@ typedef FILE duk_file;
2011
2053
  #define DUK_UNLIKELY(x) (x)
2012
2054
  #endif
2013
2055
 
2056
+ /*
2057
+ * DUK_NOINLINE: macro to avoid inlining a function.
2058
+ */
2059
+
2060
+ #if defined(DUK_F_CLANG)
2061
+ #define DUK_NOINLINE __attribute__ ((noinline))
2062
+ #elif defined(DUK_F_GCC) && defined(DUK_F_GCC_VERSION)
2063
+ #if (DUK_F_GCC_VERSION >= 30101)
2064
+ #define DUK_NOINLINE __attribute__ ((noinline))
2065
+ #endif
2066
+ #endif
2067
+
2068
+ #if !defined(DUK_NOINLINE)
2069
+ #define DUK_NOINLINE /*nop*/
2070
+ #endif
2071
+
2014
2072
  /*
2015
2073
  * Symbol visibility macros
2074
+ *
2075
+ * To avoid C++ declaration issues (see GH-63):
2076
+ *
2077
+ * - Don't use DUK_LOCAL_DECL for local -data symbols- so that you don't
2078
+ * end up with both a "static" declaration and a definition.
2079
+ *
2080
+ * - Wrap any DUK_INTERNAL_DECL with a '#if !defined(DUK_SINGLE_FILE)'
2081
+ * so that the internal declarations (which would map to "static" in
2082
+ * a single file distribution) get dropped.
2016
2083
  */
2017
2084
 
2018
2085
  /* XXX: user override for these? user override for just using the default visibility macros? */
2019
2086
  /* XXX: separate macros for function and data may be necessary at some point. */
2020
2087
 
2021
2088
  #if defined(DUK_F_GCC_VERSION)
2022
- #if (DUK_F_GCC_VERSION >= 40000)
2023
- /* Might work on earlier versions too but limit to GCC 4+. */
2089
+ #if (DUK_F_GCC_VERSION >= 40000) && !(defined(DUK_F_MINGW) || defined(DUK_F_CYGWIN))
2090
+ /* Might work on earlier versions too but limit to GCC 4+.
2091
+ * MinGW should use Windows specific __declspec or no visibility attributes at all,
2092
+ * otherwise: "warning: visibility attribute not supported in this configuration; ignored".
2093
+ * Same applies to Cygwin GCC.
2094
+ */
2024
2095
  #define DUK_F_GCC_SYMBOL_VISIBILITY
2025
2096
  #endif
2026
2097
  #endif
@@ -2081,24 +2152,6 @@ typedef FILE duk_file;
2081
2152
  #define DUK_LOCAL_DECL static
2082
2153
  #define DUK_LOCAL static
2083
2154
 
2084
- /* In C++ one cannot declare and define "static" variables separately (GH-63).
2085
- * As a quick workaround, use "extern" instead: it makes the symbol table ugly
2086
- * but allows compilation. A better fix is to avoid the need to forward declare
2087
- * internal symbols, but it requires changes to combine_src.py.
2088
- *
2089
- * XXX: better fix is needed.
2090
- */
2091
- #if defined(DUK_F_CPP)
2092
- #undef DUK_INTERNAL_DECL
2093
- #undef DUK_INTERNAL
2094
- #undef DUK_LOCAL_DECL
2095
- #undef DUK_LOCAL
2096
- #define DUK_INTERNAL_DECL extern
2097
- #define DUK_INTERNAL /*empty*/
2098
- #define DUK_LOCAL_DECL extern
2099
- #define DUK_LOCAL /*empty*/
2100
- #endif
2101
-
2102
2155
  /*
2103
2156
  * __FILE__, __LINE__, __func__ are wrapped. Especially __func__ is a
2104
2157
  * problem because it is not available even in some compilers which try
@@ -2129,6 +2182,8 @@ typedef FILE duk_file;
2129
2182
  #define DUK_USE_ARCH_STRING "arm"
2130
2183
  #elif defined(DUK_F_MIPS)
2131
2184
  #define DUK_USE_ARCH_STRING "mips"
2185
+ #elif defined(DUK_F_SUPERH)
2186
+ #define DUK_USE_ARCH_STRING "sh"
2132
2187
  #elif defined(DUK_F_M68K)
2133
2188
  #define DUK_USE_ARCH_STRING "m68k"
2134
2189
  #elif defined(DUK_F_FLASHPLAYER)
@@ -2171,20 +2226,60 @@ typedef FILE duk_file;
2171
2226
  * Compiler string, human readable value exposed in Duktape.env
2172
2227
  */
2173
2228
 
2174
- #if defined(DUK_F_GCC)
2229
+ #if defined(DUK_F_MINGW)
2230
+ #define DUK_USE_COMPILER_STRING "mingw"
2231
+ #elif defined(DUK_F_GCC)
2232
+ #if defined(DUK_F_CPP)
2233
+ #define DUK_USE_COMPILER_STRING "g++"
2234
+ #else
2175
2235
  #define DUK_USE_COMPILER_STRING "gcc"
2236
+ #endif
2176
2237
  #elif defined(DUK_F_CLANG)
2177
2238
  #define DUK_USE_COMPILER_STRING "clang"
2178
2239
  #elif defined(DUK_F_MSVC)
2179
2240
  #define DUK_USE_COMPILER_STRING "msvc"
2180
- #elif defined(DUK_F_MINGW)
2181
- #define DUK_USE_COMPILER_STRING "mingw"
2182
2241
  #elif defined(DUK_F_VBCC)
2183
2242
  #define DUK_USE_COMPILER_STRING "vbcc"
2184
2243
  #else
2185
2244
  #define DUK_USE_COMPILER_STRING "unknown"
2186
2245
  #endif
2187
2246
 
2247
+ /*
2248
+ * Long control transfer, setjmp/longjmp or alternatives
2249
+ *
2250
+ * Signal mask is not saved (when that can be communicated to the platform)
2251
+ */
2252
+
2253
+ /* dummy non-zero value to be used as an argument for longjmp(), see man longjmp */
2254
+ #define DUK_LONGJMP_DUMMY_VALUE 1
2255
+
2256
+ #if defined(DUK_OPT_SETJMP)
2257
+ #define DUK_USE_SETJMP
2258
+ #elif defined(DUK_OPT_UNDERSCORE_SETJMP)
2259
+ #define DUK_USE_UNDERSCORE_SETJMP
2260
+ #elif defined(DUK_OPT_SIGSETJMP)
2261
+ #define DUK_USE_SIGSETJMP
2262
+ #elif defined(__APPLE__)
2263
+ /* Use _setjmp() on Apple by default, see GH-55. */
2264
+ #define DUK_USE_UNDERSCORE_SETJMP
2265
+ #else
2266
+ /* The most portable default is setjmp(). */
2267
+ #define DUK_USE_SETJMP
2268
+ #endif
2269
+
2270
+ #if defined(DUK_USE_UNDERSCORE_SETJMP)
2271
+ #define DUK_SETJMP(jb) _setjmp((jb))
2272
+ #define DUK_LONGJMP(jb) _longjmp((jb), DUK_LONGJMP_DUMMY_VALUE)
2273
+ #elif defined(DUK_USE_SIGSETJMP)
2274
+ #define DUK_SETJMP(jb) sigsetjmp((jb), 0 /*savesigs*/)
2275
+ #define DUK_LONGJMP(jb) siglongjmp((jb), DUK_LONGJMP_DUMMY_VALUE)
2276
+ #elif defined(DUK_USE_SETJMP)
2277
+ #define DUK_SETJMP(jb) setjmp((jb))
2278
+ #define DUK_LONGJMP(jb) longjmp((jb), DUK_LONGJMP_DUMMY_VALUE)
2279
+ #else
2280
+ #error internal error
2281
+ #endif
2282
+
2188
2283
  /*
2189
2284
  * Tagged type representation (duk_tval)
2190
2285
  */
@@ -2238,6 +2333,19 @@ typedef FILE duk_file;
2238
2333
  #define DUK_USE_GC_TORTURE
2239
2334
  #endif
2240
2335
 
2336
+ /*
2337
+ * String table options
2338
+ */
2339
+
2340
+ #if defined(DUK_OPT_STRTAB_CHAIN) && defined(DUK_OPT_STRTAB_CHAIN_SIZE)
2341
+ /* Low memory algorithm: separate chaining using arrays, fixed size hash */
2342
+ #define DUK_USE_STRTAB_CHAIN
2343
+ #define DUK_USE_STRTAB_CHAIN_SIZE DUK_OPT_STRTAB_CHAIN_SIZE
2344
+ #else
2345
+ /* Default algorithm: open addressing (probing) */
2346
+ #define DUK_USE_STRTAB_PROBE
2347
+ #endif
2348
+
2241
2349
  /*
2242
2350
  * Error handling options
2243
2351
  */
@@ -2363,6 +2471,11 @@ typedef FILE duk_file;
2363
2471
  #define DUK_USE_MATH_BUILTIN
2364
2472
  #endif
2365
2473
 
2474
+ #define DUK_USE_STRICT_DECL
2475
+ #if defined(DUK_OPT_NO_STRICT_DECL)
2476
+ #undef DUK_USE_STRICT_DECL
2477
+ #endif
2478
+
2366
2479
  #define DUK_USE_REGEXP_SUPPORT
2367
2480
  #if defined(DUK_OPT_NO_REGEXP_SUPPORT)
2368
2481
  #undef DUK_USE_REGEXP_SUPPORT
@@ -2489,6 +2602,20 @@ typedef FILE duk_file;
2489
2602
  #undef DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
2490
2603
  #endif
2491
2604
 
2605
+ /* JSON escaping of U+2028 and U+2029.
2606
+ */
2607
+
2608
+ #define DUK_USE_NONSTD_JSON_ESC_U2028_U2029
2609
+ #if defined(DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029)
2610
+ #undef DUK_USE_NONSTD_JSON_ESC_U2028_U2029
2611
+ #endif
2612
+
2613
+ /* Allow 32-bit codepoints in String.fromCharCode. */
2614
+ #define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
2615
+ #if defined(DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT)
2616
+ #undef DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
2617
+ #endif
2618
+
2492
2619
  /*
2493
2620
  * Tailcalls
2494
2621
  */
@@ -2530,6 +2657,11 @@ typedef FILE duk_file;
2530
2657
  #define DUK_USE_ESBC_MAX_LINENUMBER 0x7fff0000L
2531
2658
  #define DUK_USE_ESBC_MAX_BYTES 0x7fff0000L
2532
2659
 
2660
+ #undef DUK_USE_SHUFFLE_TORTURE
2661
+ #if defined(DUK_OPT_SHUFFLE_TORTURE)
2662
+ #define DUK_USE_SHUFFLE_TORTURE
2663
+ #endif
2664
+
2533
2665
  /*
2534
2666
  * User panic handler, panic exit behavior for default panic handler
2535
2667
  */
@@ -2607,6 +2739,105 @@ typedef FILE duk_file;
2607
2739
  #define DUK_USE_USER_INITJS (DUK_OPT_USER_INITJS)
2608
2740
  #endif
2609
2741
 
2742
+ /*
2743
+ * External string data support
2744
+ *
2745
+ * Allow duk_hstrings to store data also behind an external pointer (see
2746
+ * duk_hstring_external). This increases code size slightly but is useful
2747
+ * in low memory environments where memory is more limited than flash.
2748
+ */
2749
+
2750
+ #undef DUK_USE_HSTRING_EXTDATA
2751
+ #if defined(DUK_OPT_EXTERNAL_STRINGS)
2752
+ #define DUK_USE_HSTRING_EXTDATA
2753
+ #endif
2754
+
2755
+ #undef DUK_USE_EXTSTR_INTERN_CHECK
2756
+ #if defined(DUK_OPT_EXTERNAL_STRINGS) && defined(DUK_OPT_EXTSTR_INTERN_CHECK)
2757
+ #define DUK_USE_EXTSTR_INTERN_CHECK(udata,ptr,len) DUK_OPT_EXTSTR_INTERN_CHECK((udata), (ptr), (len))
2758
+ #endif
2759
+
2760
+ #undef DUK_USE_EXTSTR_FREE
2761
+ #if defined(DUK_OPT_EXTERNAL_STRINGS) && defined(DUK_OPT_EXTSTR_FREE)
2762
+ #define DUK_USE_EXTSTR_FREE(udata,ptr) DUK_OPT_EXTSTR_FREE((udata), (ptr))
2763
+ #endif
2764
+
2765
+ /*
2766
+ * Lightweight functions
2767
+ */
2768
+
2769
+ /* Force built-ins to use lightfunc function pointers when possible. This
2770
+ * makes the built-in functions non-compliant with respect to their property
2771
+ * values and such, but is very useful in low memory environments (can save
2772
+ * around 14kB of initial RAM footprint).
2773
+ */
2774
+ #undef DUK_USE_LIGHTFUNC_BUILTINS
2775
+ #if defined(DUK_OPT_LIGHTFUNC_BUILTINS)
2776
+ #define DUK_USE_LIGHTFUNC_BUILTINS
2777
+ #endif
2778
+
2779
+ /*
2780
+ * Pointer compression and 16-bit header fields for low memory environments
2781
+ */
2782
+
2783
+ #undef DUK_USE_HEAPPTR16
2784
+ #undef DUK_USE_HEAPPTR_ENC16
2785
+ #undef DUK_USE_HEAPPTR_DEC16
2786
+ #if defined(DUK_OPT_HEAPPTR16) && defined(DUK_OPT_HEAPPTR_ENC16) && defined(DUK_OPT_HEAPPTR_DEC16)
2787
+ #define DUK_USE_HEAPPTR16
2788
+ #define DUK_USE_HEAPPTR_ENC16(udata,ptr) DUK_OPT_HEAPPTR_ENC16((udata),(ptr))
2789
+ #define DUK_USE_HEAPPTR_DEC16(udata,ptr) DUK_OPT_HEAPPTR_DEC16((udata),(ptr))
2790
+ #endif
2791
+
2792
+ #undef DUK_USE_DATAPTR16
2793
+ #undef DUK_USE_DATAPTR_ENC16
2794
+ #undef DUK_USE_DATAPTR_DEC16
2795
+ #if defined(DUK_OPT_DATAPTR16) && defined(DUK_OPT_DATAPTR_ENC16) && defined(DUK_OPT_DATAPTR_DEC16)
2796
+ #define DUK_USE_DATAPTR16
2797
+ #define DUK_USE_DATAPTR_ENC16(udata,ptr) DUK_OPT_DATAPTR_ENC16((udata),(ptr))
2798
+ #define DUK_USE_DATAPTR_DEC16(udata,ptr) DUK_OPT_DATAPTR_DEC16((udata),(ptr))
2799
+ #endif
2800
+
2801
+ #undef DUK_USE_FUNCPTR16
2802
+ #undef DUK_USE_FUNCPTR_ENC16
2803
+ #undef DUK_USE_FUNCPTR_DEC16
2804
+ #if defined(DUK_OPT_FUNCPTR16) && defined(DUK_OPT_FUNCPTR_ENC16) && defined(DUK_OPT_FUNCPTR_DEC16)
2805
+ #define DUK_USE_FUNCPTR16
2806
+ #define DUK_USE_FUNCPTR_ENC16(udata,ptr) DUK_OPT_FUNCPTR_ENC16((udata),(ptr))
2807
+ #define DUK_USE_FUNCPTR_DEC16(udata,ptr) DUK_OPT_FUNCPTR_DEC16((udata),(ptr))
2808
+ #endif
2809
+
2810
+ #undef DUK_USE_REFCOUNT16
2811
+ #if defined(DUK_OPT_REFCOUNT16)
2812
+ #define DUK_USE_REFCOUNT16
2813
+ #endif
2814
+
2815
+ #undef DUK_USE_STRHASH16
2816
+ #if defined(DUK_OPT_STRHASH16)
2817
+ #define DUK_USE_STRHASH16
2818
+ #endif
2819
+
2820
+ #undef DUK_USE_STRLEN16
2821
+ #if defined(DUK_OPT_STRLEN16)
2822
+ #define DUK_USE_STRLEN16
2823
+ #endif
2824
+
2825
+ #undef DUK_USE_BUFLEN16
2826
+ #if defined(DUK_OPT_BUFLEN16)
2827
+ #define DUK_USE_BUFLEN16
2828
+ #endif
2829
+
2830
+ #undef DUK_USE_OBJSIZES16
2831
+ #if defined(DUK_OPT_OBJSIZES16)
2832
+ #define DUK_USE_OBJSIZES16
2833
+ #endif
2834
+
2835
+ /* For now, hash part is dropped if and only if 16-bit object fields are used. */
2836
+ #define DUK_USE_HOBJECT_HASH_PART
2837
+ #if defined(DUK_USE_OBJSIZES16)
2838
+ #undef DUK_USE_HOBJECT_HASH_PART
2839
+ #endif
2840
+
2610
2841
  /*
2611
2842
  * Miscellaneous
2612
2843
  */
@@ -2778,7 +3009,13 @@ struct duk_number_list_entry {
2778
3009
  * have 99 for patch level (e.g. 0.10.99 would be a development version
2779
3010
  * after 0.10.0 but before the next official release).
2780
3011
  */
2781
- #define DUK_VERSION 10002L
3012
+ #define DUK_VERSION 10102L
3013
+
3014
+ /* Git describe for Duktape build. Useful for non-official snapshot builds
3015
+ * so that application code can easily log which Duktape snapshot was used.
3016
+ * Not available in the Ecmascript environment.
3017
+ */
3018
+ #define DUK_GIT_DESCRIBE "v1.1.2"
2782
3019
 
2783
3020
  /* Used to represent invalid index; if caller uses this without checking,
2784
3021
  * this index will map to a non-existent stack entry. Also used in some
@@ -2806,6 +3043,7 @@ struct duk_number_list_entry {
2806
3043
  #define DUK_TYPE_OBJECT 6 /* Ecmascript object: includes objects, arrays, functions, threads */
2807
3044
  #define DUK_TYPE_BUFFER 7 /* fixed or dynamic, garbage collected byte buffer */
2808
3045
  #define DUK_TYPE_POINTER 8 /* raw void pointer */
3046
+ #define DUK_TYPE_LIGHTFUNC 9 /* lightweight function pointer */
2809
3047
 
2810
3048
  /* Value mask types, used by e.g. duk_get_type_mask() */
2811
3049
  #define DUK_TYPE_MASK_NONE (1 << DUK_TYPE_NONE)
@@ -2817,6 +3055,7 @@ struct duk_number_list_entry {
2817
3055
  #define DUK_TYPE_MASK_OBJECT (1 << DUK_TYPE_OBJECT)
2818
3056
  #define DUK_TYPE_MASK_BUFFER (1 << DUK_TYPE_BUFFER)
2819
3057
  #define DUK_TYPE_MASK_POINTER (1 << DUK_TYPE_POINTER)
3058
+ #define DUK_TYPE_MASK_LIGHTFUNC (1 << DUK_TYPE_LIGHTFUNC)
2820
3059
  #define DUK_TYPE_MASK_THROW (1 << 10) /* internal flag value: throw if mask doesn't match */
2821
3060
 
2822
3061
  /* Coercion hints */
@@ -2843,6 +3082,18 @@ struct duk_number_list_entry {
2843
3082
  #define DUK_COMPILE_NOSOURCE (1 << 5) /* (internal) no source string on stack */
2844
3083
  #define DUK_COMPILE_STRLEN (1 << 6) /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */
2845
3084
 
3085
+ /* Flags for duk_def_prop() and its variants */
3086
+ #define DUK_DEFPROP_WRITABLE (1 << 0) /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */
3087
+ #define DUK_DEFPROP_ENUMERABLE (1 << 1) /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */
3088
+ #define DUK_DEFPROP_CONFIGURABLE (1 << 2) /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */
3089
+ #define DUK_DEFPROP_HAVE_WRITABLE (1 << 3) /* set/clear writable */
3090
+ #define DUK_DEFPROP_HAVE_ENUMERABLE (1 << 4) /* set/clear enumerable */
3091
+ #define DUK_DEFPROP_HAVE_CONFIGURABLE (1 << 5) /* set/clear configurable */
3092
+ #define DUK_DEFPROP_HAVE_VALUE (1 << 6) /* set value (given on value stack) */
3093
+ #define DUK_DEFPROP_HAVE_GETTER (1 << 7) /* set getter (given on value stack) */
3094
+ #define DUK_DEFPROP_HAVE_SETTER (1 << 8) /* set setter (given on value stack) */
3095
+ #define DUK_DEFPROP_FORCE (1 << 9) /* force change if possible, may still fail for e.g. virtual properties */
3096
+
2846
3097
  /* Flags for duk_push_thread_raw() */
2847
3098
  #define DUK_THREAD_NEW_GLOBAL_ENV (1 << 0) /* create a new global environment */
2848
3099
 
@@ -2850,6 +3101,7 @@ struct duk_number_list_entry {
2850
3101
  #define DUK_STRING_PUSH_SAFE (1 << 0) /* no error if file does not exist */
2851
3102
 
2852
3103
  /* Duktape specific error codes */
3104
+ #define DUK_ERR_NONE 0 /* no error (e.g. from duk_get_error_code()) */
2853
3105
  #define DUK_ERR_UNIMPLEMENTED_ERROR 50 /* UnimplementedError */
2854
3106
  #define DUK_ERR_UNSUPPORTED_ERROR 51 /* UnsupportedError */
2855
3107
  #define DUK_ERR_INTERNAL_ERROR 52 /* InternalError */
@@ -2913,7 +3165,7 @@ DUK_EXTERNAL_DECL
2913
3165
  duk_context *duk_create_heap(duk_alloc_function alloc_func,
2914
3166
  duk_realloc_function realloc_func,
2915
3167
  duk_free_function free_func,
2916
- void *alloc_udata,
3168
+ void *heap_udata,
2917
3169
  duk_fatal_function fatal_handler);
2918
3170
  DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);
2919
3171
 
@@ -2940,11 +3192,13 @@ DUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);
2940
3192
  */
2941
3193
 
2942
3194
  DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw(duk_context *ctx));
3195
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg));
2943
3196
 
2944
3197
  DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...));
3198
+
2945
3199
  #ifdef DUK_API_VARIADIC_MACROS
2946
3200
  #define duk_error(ctx,err_code,...) \
2947
- duk_error_raw((ctx), (duk_errcode_t) (err_code), __FILE__, (duk_int_t) __LINE__, __VA_ARGS__)
3201
+ duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), __VA_ARGS__)
2948
3202
  #else
2949
3203
  DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
2950
3204
  /* One problem with this macro is that expressions like the following fail
@@ -2952,12 +3206,14 @@ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_er
2952
3206
  * they make little sense anyway.
2953
3207
  */
2954
3208
  #define duk_error \
2955
- duk_api_global_filename = __FILE__, \
2956
- duk_api_global_line = (duk_int_t) __LINE__, \
2957
- duk_error_stash /* arguments follow */
3209
+ (duk_api_global_filename = (const char *) (__FILE__), \
3210
+ duk_api_global_line = (duk_int_t) (__LINE__), \
3211
+ duk_error_stash) /* last value is func pointer, arguments follow in parens */
2958
3212
  #endif
2959
3213
 
2960
- DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg));
3214
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap));
3215
+ #define duk_error_va(ctx,err_code,fmt,ap) \
3216
+ duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
2961
3217
 
2962
3218
  /*
2963
3219
  * Other state related functions
@@ -3050,6 +3306,7 @@ DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *targ
3050
3306
  DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);
3051
3307
  DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);
3052
3308
  DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);
3309
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic);
3053
3310
  DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);
3054
3311
 
3055
3312
  #define duk_push_thread(ctx) \
@@ -3059,20 +3316,33 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t fla
3059
3316
  duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)
3060
3317
 
3061
3318
  DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...);
3319
+
3062
3320
  #ifdef DUK_API_VARIADIC_MACROS
3063
3321
  #define duk_push_error_object(ctx,err_code,...) \
3064
- duk_push_error_object_raw((ctx),(err_code),__FILE__,__LINE__,__VA_ARGS__)
3322
+ duk_push_error_object_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), __VA_ARGS__)
3065
3323
  #else
3066
3324
  DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
3325
+ /* Note: parentheses are required so that the comma expression works in assignments. */
3067
3326
  #define duk_push_error_object \
3068
- duk_api_global_filename = __FILE__, \
3069
- duk_api_global_line = __LINE__, \
3070
- duk_push_error_object_stash /* arguments follow */
3327
+ (duk_api_global_filename = (const char *) (__FILE__), \
3328
+ duk_api_global_line = (duk_int_t) (__LINE__), \
3329
+ duk_push_error_object_stash) /* last value is func pointer, arguments follow in parens */
3071
3330
  #endif
3072
3331
 
3073
- DUK_EXTERNAL_DECL void *duk_push_buffer(duk_context *ctx, duk_size_t size, duk_bool_t dynamic);
3074
- DUK_EXTERNAL_DECL void *duk_push_fixed_buffer(duk_context *ctx, duk_size_t size);
3075
- DUK_EXTERNAL_DECL void *duk_push_dynamic_buffer(duk_context *ctx, duk_size_t size);
3332
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);
3333
+ #define duk_push_error_object_va(ctx,err_code,fmt,ap) \
3334
+ duk_push_error_object_va_raw((ctx), (err_code), (const char *) (__FILE__), (duk_int_t) (__LINE__), (fmt), (ap))
3335
+
3336
+ DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_bool_t dynamic);
3337
+
3338
+ #define duk_push_buffer(ctx,size,dynamic) \
3339
+ duk_push_buffer_raw((ctx), (size), (dynamic));
3340
+ #define duk_push_fixed_buffer(ctx,size) \
3341
+ duk_push_buffer_raw((ctx), (size), 0 /*dynamic*/)
3342
+ #define duk_push_dynamic_buffer(ctx,size) \
3343
+ duk_push_buffer_raw((ctx), (size), 1 /*dynamic*/)
3344
+
3345
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr);
3076
3346
 
3077
3347
  /*
3078
3348
  * Pop operations
@@ -3105,6 +3375,7 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index);
3105
3375
  DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index);
3106
3376
  DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index);
3107
3377
  DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index);
3378
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index);
3108
3379
 
3109
3380
  DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index);
3110
3381
  DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index);
@@ -3124,7 +3395,12 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t index)
3124
3395
  DUK_TYPE_MASK_STRING | \
3125
3396
  DUK_TYPE_MASK_OBJECT | \
3126
3397
  DUK_TYPE_MASK_BUFFER | \
3127
- DUK_TYPE_MASK_POINTER)
3398
+ DUK_TYPE_MASK_POINTER | \
3399
+ DUK_TYPE_MASK_LIGHTFUNC)
3400
+
3401
+ DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index);
3402
+ #define duk_is_error(ctx,index) \
3403
+ (duk_get_error_code((ctx), (index)) != 0)
3128
3404
 
3129
3405
  /*
3130
3406
  * Get operations: no coercion, returns default value for invalid
@@ -3144,6 +3420,7 @@ DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_si
3144
3420
  DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t index);
3145
3421
  DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index);
3146
3422
  DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t index);
3423
+ DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t index);
3147
3424
  DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
3148
3425
 
3149
3426
  /*
@@ -3166,6 +3443,7 @@ DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t index, du
3166
3443
  DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
3167
3444
  DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
3168
3445
  DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
3446
+ DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
3169
3447
 
3170
3448
  #define duk_require_object_coercible(ctx,index) \
3171
3449
  ((void) duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
@@ -3174,6 +3452,7 @@ DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t i
3174
3452
  DUK_TYPE_MASK_OBJECT | \
3175
3453
  DUK_TYPE_MASK_BUFFER | \
3176
3454
  DUK_TYPE_MASK_POINTER | \
3455
+ DUK_TYPE_MASK_LIGHTFUNC | \
3177
3456
  DUK_TYPE_MASK_THROW))
3178
3457
 
3179
3458
  /*
@@ -3194,14 +3473,23 @@ DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index);
3194
3473
  DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t index);
3195
3474
  DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t index);
3196
3475
  DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3197
- DUK_EXTERNAL_DECL void *duk_to_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
3198
- DUK_EXTERNAL_DECL void *duk_to_fixed_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
3199
- DUK_EXTERNAL_DECL void *duk_to_dynamic_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
3476
+ DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t flags);
3200
3477
  DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t index);
3201
3478
  DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t index);
3202
3479
  DUK_EXTERNAL_DECL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint);
3203
3480
  DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint);
3204
3481
 
3482
+ #define DUK_BUF_MODE_FIXED 0 /* internal: request fixed buffer result */
3483
+ #define DUK_BUF_MODE_DYNAMIC 1 /* internal: request dynamic buffer result */
3484
+ #define DUK_BUF_MODE_DONTCARE 2 /* internal: don't care about fixed/dynamic nature */
3485
+
3486
+ #define duk_to_buffer(ctx,index,out_size) \
3487
+ duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)
3488
+ #define duk_to_fixed_buffer(ctx,index,out_size) \
3489
+ duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)
3490
+ #define duk_to_dynamic_buffer(ctx,index,out_size) \
3491
+ duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DYNAMIC)
3492
+
3205
3493
  /* safe variants of a few coercion operations */
3206
3494
  DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3207
3495
  #define duk_safe_to_string(ctx,index) \
@@ -3244,6 +3532,7 @@ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_
3244
3532
  DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index);
3245
3533
  DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3246
3534
  DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3535
+ DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags);
3247
3536
 
3248
3537
  DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);
3249
3538
  DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);
@@ -3352,19 +3641,19 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
3352
3641
 
3353
3642
  /* plain */
3354
3643
  #define duk_eval(ctx) \
3355
- ((void) duk_push_string((ctx), __FILE__), \
3644
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3356
3645
  (void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL))
3357
3646
 
3358
3647
  #define duk_eval_noresult(ctx) \
3359
- ((void) duk_push_string((ctx), __FILE__), \
3648
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3360
3649
  (void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
3361
3650
 
3362
3651
  #define duk_peval(ctx) \
3363
- ((void) duk_push_string((ctx), __FILE__), \
3652
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3364
3653
  duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
3365
3654
 
3366
3655
  #define duk_peval_noresult(ctx) \
3367
- ((void) duk_push_string((ctx), __FILE__), \
3656
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3368
3657
  duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
3369
3658
 
3370
3659
  #define duk_compile(ctx,flags) \
@@ -3375,30 +3664,30 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
3375
3664
 
3376
3665
  /* string */
3377
3666
  #define duk_eval_string(ctx,src) \
3378
- ((void) duk_push_string((ctx), __FILE__), \
3667
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3379
3668
  (void) duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
3380
3669
 
3381
3670
  #define duk_eval_string_noresult(ctx,src) \
3382
- ((void) duk_push_string((ctx), __FILE__), \
3671
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3383
3672
  (void) duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT))
3384
3673
 
3385
3674
  #define duk_peval_string(ctx,src) \
3386
- ((void) duk_push_string((ctx), __FILE__), \
3675
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3387
3676
  duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
3388
3677
 
3389
3678
  #define duk_peval_string_noresult(ctx,src) \
3390
- ((void) duk_push_string((ctx), __FILE__), \
3679
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3391
3680
  duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT))
3392
3681
 
3393
3682
  #define duk_compile_string(ctx,flags,src) \
3394
- ((void) duk_push_string((ctx), __FILE__), \
3683
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3395
3684
  (void) duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
3396
3685
 
3397
3686
  #define duk_compile_string_filename(ctx,flags,src) \
3398
3687
  ((void) duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
3399
3688
 
3400
3689
  #define duk_pcompile_string(ctx,flags,src) \
3401
- ((void) duk_push_string((ctx), __FILE__), \
3690
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3402
3691
  duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
3403
3692
 
3404
3693
  #define duk_pcompile_string_filename(ctx,flags,src) \
@@ -3406,30 +3695,30 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
3406
3695
 
3407
3696
  /* lstring */
3408
3697
  #define duk_eval_lstring(ctx,buf,len) \
3409
- ((void) duk_push_string((ctx), __FILE__), \
3698
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3410
3699
  (void) duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE))
3411
3700
 
3412
3701
  #define duk_eval_lstring_noresult(ctx,buf,len) \
3413
- ((void) duk_push_string((ctx), __FILE__), \
3702
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3414
3703
  (void) duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT))
3415
3704
 
3416
3705
  #define duk_peval_lstring(ctx,buf,len) \
3417
- ((void) duk_push_string((ctx), __FILE__), \
3706
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3418
3707
  duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE))
3419
3708
 
3420
3709
  #define duk_peval_lstring_noresult(ctx,buf,len) \
3421
- ((void) duk_push_string((ctx), __FILE__), \
3710
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3422
3711
  duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT))
3423
3712
 
3424
3713
  #define duk_compile_lstring(ctx,flags,buf,len) \
3425
- ((void) duk_push_string((ctx), __FILE__), \
3714
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3426
3715
  (void) duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_NOSOURCE))
3427
3716
 
3428
3717
  #define duk_compile_lstring_filename(ctx,flags,buf,len) \
3429
3718
  ((void) duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_NOSOURCE))
3430
3719
 
3431
3720
  #define duk_pcompile_lstring(ctx,flags,buf,len) \
3432
- ((void) duk_push_string((ctx), __FILE__), \
3721
+ ((void) duk_push_string((ctx), (const char *) (__FILE__)), \
3433
3722
  duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
3434
3723
 
3435
3724
  #define duk_pcompile_lstring_filename(ctx,flags,buf,len) \
@@ -3471,6 +3760,7 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
3471
3760
  */
3472
3761
 
3473
3762
  DUK_EXTERNAL_DECL void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);
3763
+ DUK_EXTERNAL_DECL void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap);
3474
3764
 
3475
3765
  /*
3476
3766
  * Debugging
@@ -3572,6 +3862,11 @@ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
3572
3862
  #error DUK_USE_DDDPRINT without DUK_USE_DEBUG
3573
3863
  #endif
3574
3864
 
3865
+ #if defined(DUK_USE_HEAPPTR16) && defined(DUK_USE_DEBUG)
3866
+ /* Debug code doesn't have access to 'heap' so it cannot decode pointers. */
3867
+ #error debug printing cannot currently be used with heap pointer compression
3868
+ #endif
3869
+
3575
3870
  /*
3576
3871
  * Garbage collection consistency
3577
3872
  */
@@ -3584,6 +3879,23 @@ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
3584
3879
  #error DUK_USE_GC_TORTURE defined without DUK_USE_MARK_AND_SWEEP
3585
3880
  #endif
3586
3881
 
3882
+ /*
3883
+ * Low memory feature consistency
3884
+ */
3885
+
3886
+ #if defined(DUK_USE_OBJSIZES16)
3887
+ #if defined(DUK_USE_HOBJECT_HASH_PART)
3888
+ #error DUK_USE_OBJSIZES16 assumes DUK_USE_HOBJECT_HASH_PART is not defined
3889
+ #endif
3890
+ #endif
3891
+
3892
+ #if defined(DUK_USE_STRTAB_CHAIN) && defined(DUK_USE_STRTAB_PROBE)
3893
+ #error both DUK_USE_STRTAB_CHAIN and DUK_USE_STRTAB_PROBE defined
3894
+ #endif
3895
+ #if !defined(DUK_USE_STRTAB_CHAIN) && !defined(DUK_USE_STRTAB_PROBE)
3896
+ #error neither DUK_USE_STRTAB_CHAIN nor DUK_USE_STRTAB_PROBE is defined
3897
+ #endif
3898
+
3587
3899
  #endif /* DUK_FEATURES_SANITY_H_INCLUDED */
3588
3900
 
3589
3901
  /*