duktape 0.11.0.0 → 1.0.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,13 +1,13 @@
1
1
  /*
2
- * Duktape public API for Duktape 0.11.0.
2
+ * Duktape public API for Duktape 1.0.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 621b545c474dd7a3def7aefed0557b1a825a4578 (v0.10.0-827-g621b545).
8
+ * Git commit a476318bf025137c2847c808a8334d8b7db985f2 (v1.0.2).
9
9
  *
10
- * See Duktape AUTHORS.txt and LICENSE.txt for copyright and
10
+ * See Duktape AUTHORS.rst and LICENSE.txt for copyright and
11
11
  * licensing information.
12
12
  */
13
13
 
@@ -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.txt)
22
+ * Copyright (c) 2013-2014 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
@@ -41,7 +41,7 @@
41
41
  *
42
42
  */
43
43
 
44
- /* AUTHORS.txt */
44
+ /* AUTHORS.rst */
45
45
  /*
46
46
  * ===============
47
47
  * Duktape authors
@@ -88,11 +88,14 @@
88
88
  * * Andreas \u00d6man
89
89
  * * Doug Sanden
90
90
  * * Remo Eichenberger (https://github.com/remoe)
91
+ * * David Demelier
91
92
  */
92
93
 
93
94
  #ifndef DUKTAPE_H_INCLUDED
94
95
  #define DUKTAPE_H_INCLUDED
95
96
 
97
+ #define DUK_SINGLE_FILE
98
+
96
99
  /*
97
100
  * Determine platform features, select feature selection defines
98
101
  * (e.g. _XOPEN_SOURCE), include system headers, and define DUK_USE_XXX
@@ -230,7 +233,7 @@ static __inline__ unsigned long long duk_rdtsc(void) {
230
233
  #endif
231
234
 
232
235
  /* MIPS */
233
- /* FIXME: 32-bit vs. 64-bit MIPS */
236
+ /* XXX: 32-bit vs. 64-bit MIPS */
234
237
  #if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \
235
238
  defined(_R3000) || defined(_R4000) || defined(_R5900) || \
236
239
  defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \
@@ -272,12 +275,17 @@ static __inline__ unsigned long long duk_rdtsc(void) {
272
275
  #define DUK_F_BSD
273
276
  #endif
274
277
 
275
- /* Generic Unix */
278
+ /* Generic Unix (includes Cygwin) */
276
279
  #if defined(__unix) || defined(__unix__) || defined(unix) || \
277
280
  defined(DUK_F_LINUX) || defined(DUK_F_BSD)
278
281
  #define DUK_F_UNIX
279
282
  #endif
280
283
 
284
+ /* Cygwin */
285
+ #if defined(__CYGWIN__)
286
+ #define DUK_F_CYGWIN
287
+ #endif
288
+
281
289
  /* Windows (32-bit or above) */
282
290
  #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \
283
291
  defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
@@ -328,6 +336,13 @@ static __inline__ unsigned long long duk_rdtsc(void) {
328
336
  /* Clang */
329
337
  #if defined(__clang__)
330
338
  #define DUK_F_CLANG
339
+ /* It seems clang also defines __GNUC__, so undo the GCC detection. */
340
+ #if defined(DUK_F_GCC)
341
+ #undef DUK_F_GCC
342
+ #endif
343
+ #if defined(DUK_F_GCC_VERSION)
344
+ #undef DUK_F_GCC_VERSION
345
+ #endif
331
346
  #endif
332
347
 
333
348
  /* MSVC */
@@ -337,7 +352,14 @@ static __inline__ unsigned long long duk_rdtsc(void) {
337
352
  * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp
338
353
  */
339
354
  #define DUK_F_MSVC
355
+ #if defined(_MSC_FULL_VER)
356
+ #if (_MSC_FULL_VER > 100000000)
357
+ #define DUK_F_MSVC_FULL_VER _MSC_FULL_VER
358
+ #else
359
+ #define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)
340
360
  #endif
361
+ #endif
362
+ #endif /* _MSC_VER */
341
363
 
342
364
  /* MinGW */
343
365
  #if defined(__MINGW32__) || defined(__MINGW64__)
@@ -393,7 +415,7 @@ static __inline__ unsigned long long duk_rdtsc(void) {
393
415
  * #ifdefs, but it would then be more difficult to make fixes which
394
416
  * affect only a specific platform.
395
417
  *
396
- * FIXME: add a way to provide custom functions to provide the critical
418
+ * XXX: add a way to provide custom functions to provide the critical
397
419
  * primitives; this would be convenient when porting to unknown platforms
398
420
  * (rather than muck with Duktape internals).
399
421
  */
@@ -563,6 +585,17 @@ static __inline__ unsigned long long duk_rdtsc(void) {
563
585
  #include <sys/param.h>
564
586
  #include <sys/time.h>
565
587
  #include <time.h>
588
+ #elif defined(DUK_F_CYGWIN)
589
+ /* Cygwin -- don't use strptime() for now */
590
+ #define DUK_USE_DATE_NOW_GETTIMEOFDAY
591
+ #define DUK_USE_DATE_TZO_GMTIME_R
592
+ #define DUK_USE_DATE_FMT_STRFTIME
593
+ #include <sys/types.h>
594
+ #include <endian.h>
595
+ #include <limits.h>
596
+ #include <sys/param.h>
597
+ #include <sys/time.h>
598
+ #include <time.h>
566
599
  #else
567
600
  /* Other UNIX, hopefully others */
568
601
  #define DUK_USE_DATE_NOW_GETTIMEOFDAY
@@ -631,7 +664,7 @@ static __inline__ unsigned long long duk_rdtsc(void) {
631
664
  * being able to compare DUK_SIZE_MAX against a limit.
632
665
  */
633
666
 
634
- /* FIXME: add feature options to force basic types from outside? */
667
+ /* XXX: add feature options to force basic types from outside? */
635
668
 
636
669
  #if !defined(INT_MAX)
637
670
  #error INT_MAX not defined
@@ -1978,6 +2011,94 @@ typedef FILE duk_file;
1978
2011
  #define DUK_UNLIKELY(x) (x)
1979
2012
  #endif
1980
2013
 
2014
+ /*
2015
+ * Symbol visibility macros
2016
+ */
2017
+
2018
+ /* XXX: user override for these? user override for just using the default visibility macros? */
2019
+ /* XXX: separate macros for function and data may be necessary at some point. */
2020
+
2021
+ #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+. */
2024
+ #define DUK_F_GCC_SYMBOL_VISIBILITY
2025
+ #endif
2026
+ #endif
2027
+ #if defined(DUK_F_CLANG) && !defined(DUK_F_GCC_SYMBOL_VISIBILITY)
2028
+ #define DUK_F_GCC_SYMBOL_VISIBILITY
2029
+ #endif
2030
+ #if defined(DUK_OPT_DLL_BUILD) && defined(_WIN32) && (defined(_MSC_VER) || defined(__GNUC__))
2031
+ /* __declspec(dllexport) and __declspec(dllimport) only for Windows DLL build.
2032
+ * MSVC: any minimum version?
2033
+ * MinGW: no minimum version, even gcc-2.95.3 supported dllimport/dllexport.
2034
+ */
2035
+ #define DUK_F_MSVC_DLL_SYMBOL_VISIBILITY
2036
+ #endif
2037
+
2038
+ #if defined(DUK_F_GCC_SYMBOL_VISIBILITY)
2039
+ /* GCC 4+ visibility attributes. */
2040
+ #define DUK_EXTERNAL_DECL __attribute__ ((visibility("default"))) extern
2041
+ #define DUK_EXTERNAL __attribute__ ((visibility("default")))
2042
+ #if defined(DUK_SINGLE_FILE)
2043
+ #define DUK_INTERNAL_DECL static
2044
+ #define DUK_INTERNAL static
2045
+ #else
2046
+ #define DUK_INTERNAL_DECL __attribute__ ((visibility("hidden"))) extern
2047
+ #define DUK_INTERNAL __attribute__ ((visibility("hidden")))
2048
+ #endif
2049
+ #elif defined(DUK_F_MSVC_DLL_SYMBOL_VISIBILITY)
2050
+ /* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're
2051
+ * compiling Duktape or the application.
2052
+ */
2053
+ #if defined(DUK_COMPILING_DUKTAPE)
2054
+ #define DUK_EXTERNAL_DECL extern __declspec(dllexport)
2055
+ #define DUK_EXTERNAL __declspec(dllexport)
2056
+ #else
2057
+ #define DUK_EXTERNAL_DECL extern __declspec(dllimport)
2058
+ #define DUK_EXTERNAL should_not_happen
2059
+ #endif
2060
+ #if defined(DUK_SINGLE_FILE)
2061
+ #define DUK_INTERNAL_DECL static
2062
+ #define DUK_INTERNAL static
2063
+ #else
2064
+ #define DUK_INTERNAL_DECL extern
2065
+ #define DUK_INTERNAL /*empty*/
2066
+ #endif
2067
+ #else
2068
+ /* Default visibility. */
2069
+ #define DUK_EXTERNAL_DECL extern
2070
+ #define DUK_EXTERNAL /*empty*/
2071
+ #if defined(DUK_SINGLE_FILE)
2072
+ #define DUK_INTERNAL_DECL static
2073
+ #define DUK_INTERNAL static
2074
+ #else /* DUK_SINGLE_FILE */
2075
+ #define DUK_INTERNAL_DECL extern
2076
+ #define DUK_INTERNAL /*empty*/
2077
+ #endif
2078
+ #endif
2079
+
2080
+ /* For now, these are shared. */
2081
+ #define DUK_LOCAL_DECL static
2082
+ #define DUK_LOCAL static
2083
+
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
+
1981
2102
  /*
1982
2103
  * __FILE__, __LINE__, __func__ are wrapped. Especially __func__ is a
1983
2104
  * problem because it is not available even in some compilers which try
@@ -2018,7 +2139,53 @@ typedef FILE duk_file;
2018
2139
  #define DUK_USE_ARCH_STRING "unknown"
2019
2140
  #endif
2020
2141
 
2021
- /*
2142
+ /*
2143
+ * OS string, human readable value exposed in Duktape.env
2144
+ */
2145
+
2146
+ #if defined(DUK_F_LINUX)
2147
+ #define DUK_USE_OS_STRING "linux"
2148
+ #elif defined(DUK_F_FREEBSD)
2149
+ #define DUK_USE_OS_STRING "freebsd"
2150
+ #elif defined(DUK_F_OPENBSD)
2151
+ #define DUK_USE_OS_STRING "openbsd"
2152
+ #elif defined(DUK_F_NETBSD)
2153
+ #define DUK_USE_OS_STRING "netbsd"
2154
+ #elif defined(DUK_F_BSD)
2155
+ #define DUK_USE_OS_STRING "bsd"
2156
+ #elif defined(DUK_F_UNIX)
2157
+ #define DUK_USE_OS_STRING "unix"
2158
+ #elif defined(DUK_F_WINDOWS)
2159
+ #define DUK_USE_OS_STRING "windows"
2160
+ #elif defined(DUK_F_TOS)
2161
+ #define DUK_USE_OS_STRING "tos"
2162
+ #elif defined(DUK_F_AMIGAOS)
2163
+ #define DUK_USE_OS_STRING "amigaos"
2164
+ #elif defined(DUK_F_QNX)
2165
+ #define DUK_USE_OS_STRING "qnx"
2166
+ #else
2167
+ #define DUK_USE_OS_STRING "unknown"
2168
+ #endif
2169
+
2170
+ /*
2171
+ * Compiler string, human readable value exposed in Duktape.env
2172
+ */
2173
+
2174
+ #if defined(DUK_F_GCC)
2175
+ #define DUK_USE_COMPILER_STRING "gcc"
2176
+ #elif defined(DUK_F_CLANG)
2177
+ #define DUK_USE_COMPILER_STRING "clang"
2178
+ #elif defined(DUK_F_MSVC)
2179
+ #define DUK_USE_COMPILER_STRING "msvc"
2180
+ #elif defined(DUK_F_MINGW)
2181
+ #define DUK_USE_COMPILER_STRING "mingw"
2182
+ #elif defined(DUK_F_VBCC)
2183
+ #define DUK_USE_COMPILER_STRING "vbcc"
2184
+ #else
2185
+ #define DUK_USE_COMPILER_STRING "unknown"
2186
+ #endif
2187
+
2188
+ /*
2022
2189
  * Tagged type representation (duk_tval)
2023
2190
  */
2024
2191
 
@@ -2112,10 +2279,15 @@ typedef FILE duk_file;
2112
2279
  * Execution and debugger options
2113
2280
  */
2114
2281
 
2282
+ /* Executor interrupt disabled for 1.0 release: there is no API to use it */
2283
+ #if 0
2115
2284
  #define DUK_USE_INTERRUPT_COUNTER
2116
2285
  #if defined(DUK_OPT_NO_INTERRUPT_COUNTER)
2117
2286
  #undef DUK_USE_INTERRUPT_COUNTER
2118
2287
  #endif
2288
+ #endif
2289
+
2290
+ #undef DUK_USE_INTERRUPT_COUNTER
2119
2291
 
2120
2292
  /* For opcodes with indirect indices, check final index against stack size.
2121
2293
  * This should not be necessary because the compiler is trusted, and we don't
@@ -2228,7 +2400,7 @@ typedef FILE duk_file;
2228
2400
  /* Treat function statements (function declarations outside top level of
2229
2401
  * Program or FunctionBody) same as normal function declarations. This is
2230
2402
  * also V8 behavior. See test-dev-func-decl-outside-top.js.
2231
- */
2403
+ */
2232
2404
  #define DUK_USE_NONSTD_FUNC_STMT
2233
2405
  #if defined(DUK_OPT_NO_NONSTD_FUNC_STMT)
2234
2406
  #undef DUK_USE_NONSTD_FUNC_STMT
@@ -2242,6 +2414,22 @@ typedef FILE duk_file;
2242
2414
  #undef DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
2243
2415
  #endif
2244
2416
 
2417
+ /* Array.prototype.concat() non-standard but real world compatible behavior
2418
+ * for non-existent trailing elements.
2419
+ */
2420
+ #define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER
2421
+ #if defined(DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER)
2422
+ #undef DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER
2423
+ #endif
2424
+
2425
+ /* Array.prototype.map() non-standard but real world compatible behavior
2426
+ * for non-existent trailing elements.
2427
+ */
2428
+ #define DUK_USE_NONSTD_ARRAY_MAP_TRAILER
2429
+ #if defined(DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER)
2430
+ #undef DUK_USE_NONSTD_ARRAY_MAP_TRAILER
2431
+ #endif
2432
+
2245
2433
  /* Non-standard 'caller' property for function instances, see
2246
2434
  * test-bi-function-nonstd-caller-prop.js.
2247
2435
  */
@@ -2435,16 +2623,21 @@ typedef FILE duk_file;
2435
2623
  #undef DUK_USE_ZERO_BUFFER_DATA
2436
2624
  #endif
2437
2625
 
2626
+ #undef DUK_USE_VARIADIC_MACROS
2438
2627
  #if defined(DUK_F_C99) || (defined(DUK_F_CPP11) && defined(__GNUC__))
2439
2628
  #define DUK_USE_VARIADIC_MACROS
2440
- #else
2441
- #undef DUK_USE_VARIADIC_MACROS
2629
+ #endif
2630
+ #if defined(_MSC_VER) && !defined(DUK_USE_VARIADIC_MACROS)
2631
+ #if (_MSC_VER >= 1400)
2632
+ /* VS2005+ should have variadic macros even when they're not C99. */
2633
+ #define DUK_USE_VARIADIC_MACROS
2634
+ #endif
2442
2635
  #endif
2443
2636
 
2444
2637
  /*
2445
2638
  * Variable size array initialization.
2446
2639
  *
2447
- * Variable size array at the end of a structure is nonportable.
2640
+ * Variable size array at the end of a structure is nonportable.
2448
2641
  * There are three alternatives:
2449
2642
  *
2450
2643
  * 1) C99 (flexible array member): char buf[]
@@ -2558,16 +2751,16 @@ typedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t c
2558
2751
  typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx);
2559
2752
 
2560
2753
  struct duk_memory_functions {
2561
- duk_alloc_function alloc;
2562
- duk_realloc_function realloc;
2563
- duk_free_function free;
2754
+ duk_alloc_function alloc_func;
2755
+ duk_realloc_function realloc_func;
2756
+ duk_free_function free_func;
2564
2757
  void *udata;
2565
2758
  };
2566
2759
 
2567
2760
  struct duk_function_list_entry {
2568
2761
  const char *key;
2569
2762
  duk_c_function value;
2570
- duk_int_t nargs;
2763
+ duk_idx_t nargs;
2571
2764
  };
2572
2765
 
2573
2766
  struct duk_number_list_entry {
@@ -2585,13 +2778,13 @@ struct duk_number_list_entry {
2585
2778
  * have 99 for patch level (e.g. 0.10.99 would be a development version
2586
2779
  * after 0.10.0 but before the next official release).
2587
2780
  */
2588
- #define DUK_VERSION 1100L
2781
+ #define DUK_VERSION 10002L
2589
2782
 
2590
2783
  /* Used to represent invalid index; if caller uses this without checking,
2591
2784
  * this index will map to a non-existent stack entry. Also used in some
2592
2785
  * API calls as a marker to denote "no value".
2593
2786
  */
2594
- #define DUK_INVALID_INDEX INT_MIN
2787
+ #define DUK_INVALID_INDEX DUK_IDX_MIN
2595
2788
 
2596
2789
  /* Indicates that a native function does not have a fixed number of args,
2597
2790
  * and the argument stack should not be capped/extended at all.
@@ -2653,6 +2846,9 @@ struct duk_number_list_entry {
2653
2846
  /* Flags for duk_push_thread_raw() */
2654
2847
  #define DUK_THREAD_NEW_GLOBAL_ENV (1 << 0) /* create a new global environment */
2655
2848
 
2849
+ /* Flags for duk_push_string_file_raw() */
2850
+ #define DUK_STRING_PUSH_SAFE (1 << 0) /* no error if file does not exist */
2851
+
2656
2852
  /* Duktape specific error codes */
2657
2853
  #define DUK_ERR_UNIMPLEMENTED_ERROR 50 /* UnimplementedError */
2658
2854
  #define DUK_ERR_UNSUPPORTED_ERROR 51 /* UnsupportedError */
@@ -2692,12 +2888,12 @@ struct duk_number_list_entry {
2692
2888
  #define DUK_EXEC_ERROR 1
2693
2889
 
2694
2890
  /* Log levels */
2695
- #define DUK_LOG_TRACE 0
2696
- #define DUK_LOG_DEBUG 1
2697
- #define DUK_LOG_INFO 2
2698
- #define DUK_LOG_WARN 3
2699
- #define DUK_LOG_ERROR 4
2700
- #define DUK_LOG_FATAL 5
2891
+ #define DUK_LOG_TRACE 0
2892
+ #define DUK_LOG_DEBUG 1
2893
+ #define DUK_LOG_INFO 2
2894
+ #define DUK_LOG_WARN 3
2895
+ #define DUK_LOG_ERROR 4
2896
+ #define DUK_LOG_FATAL 5
2701
2897
 
2702
2898
  /*
2703
2899
  * If no variadic macros, __FILE__ and __LINE__ are passed through globals
@@ -2705,20 +2901,21 @@ struct duk_number_list_entry {
2705
2901
  */
2706
2902
 
2707
2903
  #ifndef DUK_API_VARIADIC_MACROS
2708
- extern const char *duk_api_global_filename;
2709
- extern duk_int_t duk_api_global_line;
2904
+ DUK_EXTERNAL_DECL const char *duk_api_global_filename;
2905
+ DUK_EXTERNAL_DECL duk_int_t duk_api_global_line;
2710
2906
  #endif
2711
2907
 
2712
2908
  /*
2713
2909
  * Context management
2714
2910
  */
2715
2911
 
2912
+ DUK_EXTERNAL_DECL
2716
2913
  duk_context *duk_create_heap(duk_alloc_function alloc_func,
2717
2914
  duk_realloc_function realloc_func,
2718
2915
  duk_free_function free_func,
2719
2916
  void *alloc_udata,
2720
2917
  duk_fatal_function fatal_handler);
2721
- void duk_destroy_heap(duk_context *ctx);
2918
+ DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);
2722
2919
 
2723
2920
  #define duk_create_heap_default() \
2724
2921
  duk_create_heap(NULL, NULL, NULL, NULL, NULL)
@@ -2729,56 +2926,59 @@ void duk_destroy_heap(duk_context *ctx);
2729
2926
  * Raw functions have no side effects (cannot trigger GC).
2730
2927
  */
2731
2928
 
2732
- void *duk_alloc_raw(duk_context *ctx, duk_size_t size);
2733
- void duk_free_raw(duk_context *ctx, void *ptr);
2734
- void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size);
2735
- void *duk_alloc(duk_context *ctx, duk_size_t size);
2736
- void duk_free(duk_context *ctx, void *ptr);
2737
- void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size);
2738
- void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs);
2739
- void duk_gc(duk_context *ctx, duk_uint_t flags);
2929
+ DUK_EXTERNAL_DECL void *duk_alloc_raw(duk_context *ctx, duk_size_t size);
2930
+ DUK_EXTERNAL_DECL void duk_free_raw(duk_context *ctx, void *ptr);
2931
+ DUK_EXTERNAL_DECL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size);
2932
+ DUK_EXTERNAL_DECL void *duk_alloc(duk_context *ctx, duk_size_t size);
2933
+ DUK_EXTERNAL_DECL void duk_free(duk_context *ctx, void *ptr);
2934
+ DUK_EXTERNAL_DECL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size);
2935
+ DUK_EXTERNAL_DECL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs);
2936
+ DUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);
2740
2937
 
2741
2938
  /*
2742
2939
  * Error handling
2743
2940
  */
2744
2941
 
2745
- DUK_API_NORETURN(void duk_throw(duk_context *ctx));
2942
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw(duk_context *ctx));
2746
2943
 
2747
- DUK_API_NORETURN(void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...));
2944
+ 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, ...));
2748
2945
  #ifdef DUK_API_VARIADIC_MACROS
2749
2946
  #define duk_error(ctx,err_code,...) \
2750
2947
  duk_error_raw((ctx), (duk_errcode_t) (err_code), __FILE__, (duk_int_t) __LINE__, __VA_ARGS__)
2751
2948
  #else
2752
- DUK_API_NORETURN(void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
2949
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
2950
+ /* One problem with this macro is that expressions like the following fail
2951
+ * to compile: "(void) duk_error(...)". But because duk_error() is noreturn,
2952
+ * they make little sense anyway.
2953
+ */
2753
2954
  #define duk_error \
2754
2955
  duk_api_global_filename = __FILE__, \
2755
2956
  duk_api_global_line = (duk_int_t) __LINE__, \
2756
2957
  duk_error_stash /* arguments follow */
2757
2958
  #endif
2758
2959
 
2759
- DUK_API_NORETURN(void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg));
2960
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg));
2760
2961
 
2761
2962
  /*
2762
2963
  * Other state related functions
2763
2964
  */
2764
2965
 
2765
- duk_bool_t duk_is_strict_call(duk_context *ctx);
2766
- duk_bool_t duk_is_constructor_call(duk_context *ctx);
2767
- duk_int_t duk_get_magic(duk_context *ctx);
2966
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call(duk_context *ctx);
2967
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);
2768
2968
 
2769
2969
  /*
2770
2970
  * Stack management
2771
2971
  */
2772
2972
 
2773
- duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index);
2774
- duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index);
2775
- duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index);
2776
- void duk_require_valid_index(duk_context *ctx, duk_idx_t index);
2973
+ DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index);
2974
+ DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index);
2975
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index);
2976
+ DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t index);
2777
2977
 
2778
- duk_idx_t duk_get_top(duk_context *ctx);
2779
- void duk_set_top(duk_context *ctx, duk_idx_t index);
2780
- duk_idx_t duk_get_top_index(duk_context *ctx);
2781
- duk_idx_t duk_require_top_index(duk_context *ctx);
2978
+ DUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);
2979
+ DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t index);
2980
+ DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);
2981
+ DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);
2782
2982
 
2783
2983
  /* Although extra/top could be an unsigned type here, using a signed type
2784
2984
  * makes the API more robust to calling code calculation errors or corner
@@ -2787,25 +2987,29 @@ duk_idx_t duk_require_top_index(duk_context *ctx);
2787
2987
  * to a large unsigned number. (This principle is used elsewhere in the
2788
2988
  * API too.)
2789
2989
  */
2790
- duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra);
2791
- void duk_require_stack(duk_context *ctx, duk_idx_t extra);
2792
- duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);
2793
- void duk_require_stack_top(duk_context *ctx, duk_idx_t top);
2990
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra);
2991
+ DUK_EXTERNAL_DECL void duk_require_stack(duk_context *ctx, duk_idx_t extra);
2992
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);
2993
+ DUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);
2794
2994
 
2795
2995
  /*
2796
2996
  * Stack manipulation (other than push/pop)
2797
2997
  */
2798
2998
 
2799
- void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
2800
- void duk_swap_top(duk_context *ctx, duk_idx_t index);
2801
- void duk_dup(duk_context *ctx, duk_idx_t from_index);
2802
- void duk_dup_top(duk_context *ctx);
2803
- void duk_insert(duk_context *ctx, duk_idx_t to_index);
2804
- void duk_replace(duk_context *ctx, duk_idx_t to_index);
2805
- void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index);
2806
- void duk_remove(duk_context *ctx, duk_idx_t index);
2807
- /* FIXME: undocumented */
2808
- void duk_xmove(duk_context *from_ctx, duk_context *to_ctx, duk_idx_t count);
2999
+ DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
3000
+ DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t index);
3001
+ DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_index);
3002
+ DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);
3003
+ DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_index);
3004
+ DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_index);
3005
+ DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index);
3006
+ DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t index);
3007
+ DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);
3008
+
3009
+ #define duk_xmove_top(to_ctx,from_ctx,count) \
3010
+ duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)
3011
+ #define duk_xcopy_top(to_ctx,from_ctx,count) \
3012
+ duk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)
2809
3013
 
2810
3014
  /*
2811
3015
  * Push operations
@@ -2816,34 +3020,37 @@ void duk_xmove(duk_context *from_ctx, duk_context *to_ctx, duk_idx_t count);
2816
3020
  * Note: duk_dup() is technically a push.
2817
3021
  */
2818
3022
 
2819
- void duk_push_undefined(duk_context *ctx);
2820
- void duk_push_null(duk_context *ctx);
2821
- void duk_push_boolean(duk_context *ctx, duk_bool_t val);
2822
- void duk_push_true(duk_context *ctx);
2823
- void duk_push_false(duk_context *ctx);
2824
- void duk_push_number(duk_context *ctx, duk_double_t val);
2825
- void duk_push_nan(duk_context *ctx);
2826
- void duk_push_int(duk_context *ctx, duk_int_t val);
2827
- void duk_push_uint(duk_context *ctx, duk_uint_t val);
2828
- const char *duk_push_string(duk_context *ctx, const char *str);
2829
- const char *duk_push_string_file(duk_context *ctx, const char *path);
2830
- const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len);
2831
- void duk_push_pointer(duk_context *ctx, void *p);
2832
- const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);
2833
- const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);
2834
-
2835
- void duk_push_this(duk_context *ctx);
2836
- void duk_push_current_function(duk_context *ctx);
2837
- void duk_push_current_thread(duk_context *ctx);
2838
- void duk_push_global_object(duk_context *ctx);
2839
- void duk_push_heap_stash(duk_context *ctx);
2840
- void duk_push_global_stash(duk_context *ctx);
2841
- void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);
2842
-
2843
- duk_idx_t duk_push_object(duk_context *ctx);
2844
- duk_idx_t duk_push_array(duk_context *ctx);
2845
- duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);
2846
- duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);
3023
+ DUK_EXTERNAL_DECL void duk_push_undefined(duk_context *ctx);
3024
+ DUK_EXTERNAL_DECL void duk_push_null(duk_context *ctx);
3025
+ DUK_EXTERNAL_DECL void duk_push_boolean(duk_context *ctx, duk_bool_t val);
3026
+ DUK_EXTERNAL_DECL void duk_push_true(duk_context *ctx);
3027
+ DUK_EXTERNAL_DECL void duk_push_false(duk_context *ctx);
3028
+ DUK_EXTERNAL_DECL void duk_push_number(duk_context *ctx, duk_double_t val);
3029
+ DUK_EXTERNAL_DECL void duk_push_nan(duk_context *ctx);
3030
+ DUK_EXTERNAL_DECL void duk_push_int(duk_context *ctx, duk_int_t val);
3031
+ DUK_EXTERNAL_DECL void duk_push_uint(duk_context *ctx, duk_uint_t val);
3032
+ DUK_EXTERNAL_DECL const char *duk_push_string(duk_context *ctx, const char *str);
3033
+ DUK_EXTERNAL_DECL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len);
3034
+ DUK_EXTERNAL_DECL void duk_push_pointer(duk_context *ctx, void *p);
3035
+ DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);
3036
+ DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);
3037
+
3038
+ DUK_EXTERNAL_DECL const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags);
3039
+ #define duk_push_string_file(ctx,path) \
3040
+ duk_push_string_file_raw((ctx), (path), 0)
3041
+
3042
+ DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx);
3043
+ DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx);
3044
+ DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx);
3045
+ DUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx);
3046
+ DUK_EXTERNAL_DECL void duk_push_heap_stash(duk_context *ctx);
3047
+ DUK_EXTERNAL_DECL void duk_push_global_stash(duk_context *ctx);
3048
+ DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);
3049
+
3050
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);
3051
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);
3052
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);
3053
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);
2847
3054
 
2848
3055
  #define duk_push_thread(ctx) \
2849
3056
  duk_push_thread_raw((ctx), 0 /*flags*/)
@@ -2851,30 +3058,30 @@ duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);
2851
3058
  #define duk_push_thread_new_globalenv(ctx) \
2852
3059
  duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)
2853
3060
 
2854
- 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, ...);
3061
+ 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, ...);
2855
3062
  #ifdef DUK_API_VARIADIC_MACROS
2856
3063
  #define duk_push_error_object(ctx,err_code,...) \
2857
3064
  duk_push_error_object_raw((ctx),(err_code),__FILE__,__LINE__,__VA_ARGS__)
2858
3065
  #else
2859
- duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
3066
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
2860
3067
  #define duk_push_error_object \
2861
3068
  duk_api_global_filename = __FILE__, \
2862
3069
  duk_api_global_line = __LINE__, \
2863
3070
  duk_push_error_object_stash /* arguments follow */
2864
3071
  #endif
2865
3072
 
2866
- void *duk_push_buffer(duk_context *ctx, duk_size_t size, duk_bool_t dynamic);
2867
- void *duk_push_fixed_buffer(duk_context *ctx, duk_size_t size);
2868
- void *duk_push_dynamic_buffer(duk_context *ctx, duk_size_t size);
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);
2869
3076
 
2870
3077
  /*
2871
3078
  * Pop operations
2872
3079
  */
2873
3080
 
2874
- void duk_pop(duk_context *ctx);
2875
- void duk_pop_n(duk_context *ctx, duk_idx_t count);
2876
- void duk_pop_2(duk_context *ctx);
2877
- void duk_pop_3(duk_context *ctx);
3081
+ DUK_EXTERNAL_DECL void duk_pop(duk_context *ctx);
3082
+ DUK_EXTERNAL_DECL void duk_pop_n(duk_context *ctx, duk_idx_t count);
3083
+ DUK_EXTERNAL_DECL void duk_pop_2(duk_context *ctx);
3084
+ DUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);
2878
3085
 
2879
3086
  /*
2880
3087
  * Type checks
@@ -2883,35 +3090,34 @@ void duk_pop_3(duk_context *ctx);
2883
3090
  * is not needed; duk_is_valid_index() gives the same information.
2884
3091
  */
2885
3092
 
2886
- /* FIXME: a duk_small_int_t suffices to represent type and type mask (at least now). */
2887
- duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index);
2888
- duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type);
2889
- duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index);
2890
- duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask);
2891
-
2892
- duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index);
2893
- duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index);
2894
- duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index);
2895
- duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index);
2896
- duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index);
2897
- duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t index);
2898
- duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index);
2899
- duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index);
2900
- duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index);
2901
- duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index);
2902
-
2903
- duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index);
2904
- duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index);
2905
- duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t index);
2906
- duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t index);
2907
- duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t index);
2908
- duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
2909
-
2910
- duk_bool_t duk_is_callable(duk_context *ctx, duk_idx_t index);
2911
- duk_bool_t duk_is_dynamic(duk_context *ctx, duk_idx_t index);
2912
- duk_bool_t duk_is_fixed(duk_context *ctx, duk_idx_t index);
2913
-
2914
- duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t index);
3093
+ DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index);
3094
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type);
3095
+ DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index);
3096
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask);
3097
+
3098
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index);
3099
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index);
3100
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index);
3101
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index);
3102
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index);
3103
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t index);
3104
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index);
3105
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index);
3106
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index);
3107
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index);
3108
+
3109
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index);
3110
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index);
3111
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t index);
3112
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t index);
3113
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t index);
3114
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
3115
+
3116
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_callable(duk_context *ctx, duk_idx_t index);
3117
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t index);
3118
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t index);
3119
+
3120
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t index);
2915
3121
  #define duk_is_object_coercible(ctx,index) \
2916
3122
  duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
2917
3123
  DUK_TYPE_MASK_NUMBER | \
@@ -2928,17 +3134,17 @@ duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t index);
2928
3134
  * are not included.
2929
3135
  */
2930
3136
 
2931
- duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t index);
2932
- duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index);
2933
- duk_int_t duk_get_int(duk_context *ctx, duk_idx_t index);
2934
- duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t index);
2935
- const char *duk_get_string(duk_context *ctx, duk_idx_t index);
2936
- const char *duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
2937
- void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
2938
- void *duk_get_pointer(duk_context *ctx, duk_idx_t index);
2939
- duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index);
2940
- duk_context *duk_get_context(duk_context *ctx, duk_idx_t index);
2941
- duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
3137
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t index);
3138
+ DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index);
3139
+ DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t index);
3140
+ DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t index);
3141
+ DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t index);
3142
+ DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3143
+ DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
3144
+ DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t index);
3145
+ DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index);
3146
+ DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t index);
3147
+ DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
2942
3148
 
2943
3149
  /*
2944
3150
  * Require operations: no coercion, throw error if index or type
@@ -2948,18 +3154,18 @@ duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
2948
3154
  #define duk_require_type_mask(ctx,index,mask) \
2949
3155
  ((void) duk_check_type_mask((ctx), (index), (mask) | DUK_TYPE_MASK_THROW))
2950
3156
 
2951
- void duk_require_undefined(duk_context *ctx, duk_idx_t index);
2952
- void duk_require_null(duk_context *ctx, duk_idx_t index);
2953
- duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t index);
2954
- duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index);
2955
- duk_int_t duk_require_int(duk_context *ctx, duk_idx_t index);
2956
- duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index);
2957
- const char *duk_require_string(duk_context *ctx, duk_idx_t index);
2958
- const char *duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
2959
- void *duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
2960
- void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
2961
- duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
2962
- duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
3157
+ DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t index);
3158
+ DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t index);
3159
+ DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t index);
3160
+ DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index);
3161
+ DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t index);
3162
+ DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index);
3163
+ DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t index);
3164
+ DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3165
+ DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
3166
+ DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
3167
+ DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
3168
+ DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
2963
3169
 
2964
3170
  #define duk_require_object_coercible(ctx,index) \
2965
3171
  ((void) duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
@@ -2977,27 +3183,27 @@ duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
2977
3183
  * or an internal error (e.g. from out of memory).
2978
3184
  */
2979
3185
 
2980
- void duk_to_undefined(duk_context *ctx, duk_idx_t index);
2981
- void duk_to_null(duk_context *ctx, duk_idx_t index);
2982
- duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index);
2983
- duk_double_t duk_to_number(duk_context *ctx, duk_idx_t index);
2984
- duk_int_t duk_to_int(duk_context *ctx, duk_idx_t index);
2985
- duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index);
2986
- duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t index);
2987
- duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index);
2988
- duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t index);
2989
- const char *duk_to_string(duk_context *ctx, duk_idx_t index);
2990
- const char *duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
2991
- void *duk_to_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
2992
- void *duk_to_fixed_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
2993
- void *duk_to_dynamic_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
2994
- void *duk_to_pointer(duk_context *ctx, duk_idx_t index);
2995
- void duk_to_object(duk_context *ctx, duk_idx_t index);
2996
- void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint); /* FIXME: small int? */
2997
- void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint); /* FIXME: small int? */
3186
+ DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t index);
3187
+ DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t index);
3188
+ DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index);
3189
+ DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t index);
3190
+ DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t index);
3191
+ DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index);
3192
+ DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t index);
3193
+ DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index);
3194
+ DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t index);
3195
+ DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t index);
3196
+ 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);
3200
+ DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t index);
3201
+ DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t index);
3202
+ DUK_EXTERNAL_DECL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint);
3203
+ DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint);
2998
3204
 
2999
3205
  /* safe variants of a few coercion operations */
3000
- const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3206
+ DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
3001
3207
  #define duk_safe_to_string(ctx,index) \
3002
3208
  duk_safe_to_lstring((ctx), (index), NULL)
3003
3209
 
@@ -3005,18 +3211,18 @@ const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *o
3005
3211
  * Misc conversion
3006
3212
  */
3007
3213
 
3008
- const char *duk_base64_encode(duk_context *ctx, duk_idx_t index);
3009
- void duk_base64_decode(duk_context *ctx, duk_idx_t index);
3010
- const char *duk_hex_encode(duk_context *ctx, duk_idx_t index);
3011
- void duk_hex_decode(duk_context *ctx, duk_idx_t index);
3012
- const char *duk_json_encode(duk_context *ctx, duk_idx_t index);
3013
- void duk_json_decode(duk_context *ctx, duk_idx_t index);
3214
+ DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index);
3215
+ DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t index);
3216
+ DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index);
3217
+ DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t index);
3218
+ DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t index);
3219
+ DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t index);
3014
3220
 
3015
3221
  /*
3016
3222
  * Buffer
3017
3223
  */
3018
3224
 
3019
- void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
3225
+ DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
3020
3226
 
3021
3227
  /*
3022
3228
  * Property access
@@ -3026,77 +3232,108 @@ void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
3026
3232
  * index as a property name (e.g. 123 is equivalent to the key "123").
3027
3233
  */
3028
3234
 
3029
- duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index);
3030
- duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3031
- duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3032
- duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index);
3033
- duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3034
- duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3035
- duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index);
3036
- duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3037
- duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3038
- duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index);
3039
- duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3040
- duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3235
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index);
3236
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3237
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3238
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index);
3239
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3240
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3241
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index);
3242
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3243
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3244
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index);
3245
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
3246
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
3041
3247
 
3042
- duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);
3248
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);
3249
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);
3250
+
3251
+ /*
3252
+ * Object prototype
3253
+ */
3254
+
3255
+ DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t index);
3256
+ DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t index);
3257
+
3258
+ /*
3259
+ * Object finalizer
3260
+ */
3261
+
3262
+ DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t index);
3263
+ DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t index);
3264
+
3265
+ /*
3266
+ * Global object
3267
+ */
3268
+
3269
+ DUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);
3270
+
3271
+ /*
3272
+ * Duktape/C function magic value
3273
+ */
3274
+
3275
+ DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index);
3276
+ DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t index, duk_int_t magic);
3277
+ DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);
3043
3278
 
3044
3279
  /*
3045
3280
  * Module helpers: put multiple function or constant properties
3046
3281
  */
3047
3282
 
3048
- void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs);
3049
- void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers);
3283
+ DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs);
3284
+ DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers);
3050
3285
 
3051
3286
  /*
3052
3287
  * Variable access
3053
3288
  */
3054
3289
 
3055
- /* FIXME: incomplete, not usable now */
3056
- void duk_get_var(duk_context *ctx);
3057
- void duk_put_var(duk_context *ctx);
3058
- duk_bool_t duk_del_var(duk_context *ctx);
3059
- duk_bool_t duk_has_var(duk_context *ctx);
3290
+ /* XXX: These calls are incomplete and not usable now. They are not (yet)
3291
+ * part of the public API.
3292
+ */
3293
+ DUK_EXTERNAL_DECL void duk_get_var(duk_context *ctx);
3294
+ DUK_EXTERNAL_DECL void duk_put_var(duk_context *ctx);
3295
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_var(duk_context *ctx);
3296
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_var(duk_context *ctx);
3060
3297
 
3061
3298
  /*
3062
3299
  * Object operations
3063
3300
  */
3064
3301
 
3065
- void duk_compact(duk_context *ctx, duk_idx_t obj_index);
3066
- void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags);
3067
- duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value);
3302
+ DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_index);
3303
+ DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags);
3304
+ DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value);
3068
3305
 
3069
3306
  /*
3070
3307
  * String manipulation
3071
3308
  */
3072
3309
 
3073
- void duk_concat(duk_context *ctx, duk_idx_t count);
3074
- void duk_join(duk_context *ctx, duk_idx_t count);
3075
- void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata);
3076
- void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata);
3077
- void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_char_offset, duk_size_t end_char_offset);
3078
- void duk_trim(duk_context *ctx, duk_idx_t index);
3079
- duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset);
3310
+ DUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);
3311
+ DUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);
3312
+ DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata);
3313
+ DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata);
3314
+ DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_char_offset, duk_size_t end_char_offset);
3315
+ DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t index);
3316
+ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset);
3080
3317
 
3081
3318
  /*
3082
3319
  * Ecmascript operators
3083
3320
  */
3084
3321
 
3085
- duk_bool_t duk_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
3086
- duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
3322
+ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
3323
+ DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
3087
3324
 
3088
3325
  /*
3089
3326
  * Function (method) calls
3090
3327
  */
3091
3328
 
3092
- void duk_call(duk_context *ctx, duk_idx_t nargs);
3093
- void duk_call_method(duk_context *ctx, duk_idx_t nargs);
3094
- void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
3095
- duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);
3096
- duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);
3097
- duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
3098
- void duk_new(duk_context *ctx, duk_idx_t nargs);
3099
- duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t nargs, duk_idx_t nrets);
3329
+ DUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);
3330
+ DUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);
3331
+ DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
3332
+ DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);
3333
+ DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);
3334
+ DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
3335
+ DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);
3336
+ DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t nargs, duk_idx_t nrets);
3100
3337
 
3101
3338
  /*
3102
3339
  * Thread management
@@ -3110,8 +3347,8 @@ duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t
3110
3347
  * Compilation and evaluation
3111
3348
  */
3112
3349
 
3113
- duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
3114
- duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
3350
+ DUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
3351
+ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
3115
3352
 
3116
3353
  /* plain */
3117
3354
  #define duk_eval(ctx) \
@@ -3200,32 +3437,32 @@ duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t s
3200
3437
 
3201
3438
  /* file */
3202
3439
  #define duk_eval_file(ctx,path) \
3203
- ((void) duk_push_string_file((ctx), (path)), \
3440
+ ((void) duk_push_string_file_raw((ctx), (path), 0), \
3204
3441
  (void) duk_push_string((ctx), (path)), \
3205
3442
  (void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL))
3206
3443
 
3207
3444
  #define duk_eval_file_noresult(ctx,path) \
3208
- ((void) duk_push_string_file((ctx), (path)), \
3445
+ ((void) duk_push_string_file_raw((ctx), (path), 0), \
3209
3446
  (void) duk_push_string((ctx), (path)), \
3210
3447
  (void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
3211
3448
 
3212
3449
  #define duk_peval_file(ctx,path) \
3213
- ((void) duk_push_string_file((ctx), (path)), \
3450
+ ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
3214
3451
  (void) duk_push_string((ctx), (path)), \
3215
3452
  duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
3216
3453
 
3217
3454
  #define duk_peval_file_noresult(ctx,path) \
3218
- ((void) duk_push_string_file((ctx), (path)), \
3455
+ ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
3219
3456
  (void) duk_push_string((ctx), (path)), \
3220
3457
  duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
3221
3458
 
3222
3459
  #define duk_compile_file(ctx,flags,path) \
3223
- ((void) duk_push_string_file((ctx), (path)), \
3460
+ ((void) duk_push_string_file_raw((ctx), (path), 0), \
3224
3461
  (void) duk_push_string((ctx), (path)), \
3225
3462
  (void) duk_compile_raw((ctx), NULL, 0, (flags)))
3226
3463
 
3227
3464
  #define duk_pcompile_file(ctx,flags,path) \
3228
- ((void) duk_push_string_file((ctx), (path)), \
3465
+ ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
3229
3466
  (void) duk_push_string((ctx), (path)), \
3230
3467
  duk_compile_raw((ctx), NULL, 0, (flags) | DUK_COMPILE_SAFE))
3231
3468
 
@@ -3233,32 +3470,29 @@ duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t s
3233
3470
  * Logging
3234
3471
  */
3235
3472
 
3236
- /* FIXME: here a small integer type would be proper */
3237
- void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);
3473
+ DUK_EXTERNAL_DECL void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);
3238
3474
 
3239
3475
  /*
3240
3476
  * Debugging
3241
3477
  */
3242
3478
 
3243
- void duk_push_context_dump(duk_context *ctx);
3479
+ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
3244
3480
 
3245
3481
  #if defined(DUK_USE_FILE_IO)
3246
3482
  /* internal use */
3247
3483
  #define duk_dump_context_filehandle(ctx,fh) \
3248
- do { \
3249
- duk_push_context_dump((ctx)); \
3250
- fprintf(stdout, "%s\n", duk_safe_to_string(ctx, -1)); \
3251
- duk_pop(ctx); \
3252
- } while (0)
3484
+ (duk_push_context_dump((ctx)), \
3485
+ DUK_FPRINTF((fh), "%s\n", duk_safe_to_string(ctx, -1)), \
3486
+ duk_pop(ctx))
3253
3487
 
3254
3488
  /* external use */
3255
3489
  #define duk_dump_context_stdout(ctx) \
3256
- duk_dump_context_filehandle(ctx,stdout)
3490
+ duk_dump_context_filehandle((ctx), DUK_STDOUT)
3257
3491
  #define duk_dump_context_stderr(ctx) \
3258
- duk_dump_context_filehandle(ctx,stderr)
3492
+ duk_dump_context_filehandle((ctx), DUK_STDERR)
3259
3493
  #else /* DUK_USE_FILE_IO */
3260
- #define duk_dump_context_stdout(ctx) do {} while (0)
3261
- #define duk_dump_context_stderr(ctx) do {} while (0)
3494
+ #define duk_dump_context_stdout(ctx) ((void) 0)
3495
+ #define duk_dump_context_stderr(ctx) ((void) 0)
3262
3496
  #endif /* DUK_USE_FILE_IO */
3263
3497
 
3264
3498
  /*
@@ -3391,7 +3625,7 @@ void duk_push_context_dump(duk_context *ctx);
3391
3625
  * Indexes of various types (8-bit, 16-bit, 32-bit) in memory relative to
3392
3626
  * the logical (big endian) order:
3393
3627
  *
3394
- * byte order duk_uint8_t duk_uint16_t duk_uint32_t
3628
+ * byte order duk_uint8_t duk_uint16_t duk_uint32_t
3395
3629
  * BE 01234567 0123 01
3396
3630
  * LE 76543210 3210 10
3397
3631
  * ME (ARM) 32107654 1032 01