duktape 1.6.1.0 → 2.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,13 @@
1
1
  /*
2
- * Duktape public API for Duktape 1.6.1.
2
+ * Duktape public API for Duktape 2.0.1.
3
3
  *
4
4
  * See the API reference for documentation on call semantics.
5
5
  * The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED
6
6
  * include guard. Other parts of the header are Duktape
7
7
  * internal and related to platform/compiler/feature detection.
8
8
  *
9
- * Git commit 34ac011501ccaa8b74684a6c45ed4eaca9e83517 (v1.6.1).
10
- * Git branch v1.6-maintenance.
9
+ * Git commit 3f5e91704aff97c754f6ef5d44aedc5e529d1b16 (v2.0.1).
10
+ * Git branch v2.0-maintenance.
11
11
  *
12
12
  * See Duktape AUTHORS.rst and LICENSE.txt for copyright and
13
13
  * licensing information.
@@ -21,7 +21,7 @@
21
21
  *
22
22
  * (http://opensource.org/licenses/MIT)
23
23
  *
24
- * Copyright (c) 2013-2016 by Duktape authors (see AUTHORS.rst)
24
+ * Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst)
25
25
  *
26
26
  * Permission is hereby granted, free of charge, to any person obtaining a copy
27
27
  * of this software and associated documentation files (the "Software"), to deal
@@ -75,6 +75,18 @@
75
75
  * * Ren\u00e9 Hollander <rene@rene8888.at>
76
76
  * * Julien Hamaide (https://github.com/crazyjul)
77
77
  * * Sebastian G\u00f6tte (https://github.com/jaseg)
78
+ * * Tomasz Magulski (https://github.com/magul)
79
+ * * \D. Bohdan (https://github.com/dbohdan)
80
+ * * Ond\u0159ej Jirman (https://github.com/megous)
81
+ * * Sa\u00fal Ibarra Corretg\u00e9 <saghul@gmail.com>
82
+ * * Jeremy HU <huxingyi@msn.com>
83
+ * * Ole Andr\u00e9 Vadla Ravn\u00e5s (https://github.com/oleavr)
84
+ * * Harold Brenes (https://github.com/harold-b)
85
+ * * Oliver Crow (https://github.com/ocrow)
86
+ * * Jakub Ch\u0142api\u0144ski (https://github.com/jchlapinski)
87
+ * * Brett Vickers (https://github.com/beevik)
88
+ * * Dominik Okwieka (https://github.com/okitec)
89
+ * * Remko Tron\u00e7on (https://el-tramo.be)
78
90
  *
79
91
  * Other contributions
80
92
  * ===================
@@ -112,13 +124,13 @@
112
124
  * * Michael Drake (https://github.com/tlsa)
113
125
  * * https://github.com/chris-y
114
126
  * * Laurent Zubiaur (https://github.com/lzubiaur)
115
- * * Ole Andr\u00e9 Vadla Ravn\u00e5s (https://github.com/oleavr)
127
+ * * Neil Kolban (https://github.com/nkolban)
116
128
  *
117
129
  * If you are accidentally missing from this list, send me an e-mail
118
130
  * (``sami.vaarala@iki.fi``) and I'll fix the omission.
119
131
  */
120
132
 
121
- #ifndef DUKTAPE_H_INCLUDED
133
+ #if !defined(DUKTAPE_H_INCLUDED)
122
134
  #define DUKTAPE_H_INCLUDED
123
135
 
124
136
  #define DUK_SINGLE_FILE
@@ -133,14 +145,14 @@
133
145
  * BEGIN PUBLIC API
134
146
  */
135
147
 
136
- #ifndef DUK_API_PUBLIC_H_INCLUDED
148
+ #if !defined(DUK_API_PUBLIC_H_INCLUDED)
137
149
  #define DUK_API_PUBLIC_H_INCLUDED
138
150
 
139
151
  /*
140
152
  * Avoid C++ name mangling
141
153
  */
142
154
 
143
- #ifdef __cplusplus
155
+ #if defined(__cplusplus)
144
156
  extern "C" {
145
157
  #endif
146
158
 
@@ -149,7 +161,7 @@ extern "C" {
149
161
  */
150
162
 
151
163
  #undef DUK_API_VARIADIC_MACROS
152
- #ifdef DUK_USE_VARIADIC_MACROS
164
+ #if defined(DUK_USE_VARIADIC_MACROS)
153
165
  #define DUK_API_VARIADIC_MACROS
154
166
  #endif
155
167
 
@@ -167,6 +179,7 @@ struct duk_thread_state;
167
179
  struct duk_memory_functions;
168
180
  struct duk_function_list_entry;
169
181
  struct duk_number_list_entry;
182
+ struct duk_time_components;
170
183
 
171
184
  /* duk_context is now defined in duk_config.h because it may also be
172
185
  * referenced there by prototypes.
@@ -175,22 +188,23 @@ typedef struct duk_thread_state duk_thread_state;
175
188
  typedef struct duk_memory_functions duk_memory_functions;
176
189
  typedef struct duk_function_list_entry duk_function_list_entry;
177
190
  typedef struct duk_number_list_entry duk_number_list_entry;
191
+ typedef struct duk_time_components duk_time_components;
178
192
 
179
193
  typedef duk_ret_t (*duk_c_function)(duk_context *ctx);
180
194
  typedef void *(*duk_alloc_function) (void *udata, duk_size_t size);
181
195
  typedef void *(*duk_realloc_function) (void *udata, void *ptr, duk_size_t size);
182
196
  typedef void (*duk_free_function) (void *udata, void *ptr);
183
- typedef void (*duk_fatal_function) (duk_context *ctx, duk_errcode_t code, const char *msg);
197
+ typedef void (*duk_fatal_function) (void *udata, const char *msg);
184
198
  typedef void (*duk_decode_char_function) (void *udata, duk_codepoint_t codepoint);
185
199
  typedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t codepoint);
186
- typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx);
200
+ typedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx, void *udata);
187
201
  typedef duk_size_t (*duk_debug_read_function) (void *udata, char *buffer, duk_size_t length);
188
202
  typedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length);
189
203
  typedef duk_size_t (*duk_debug_peek_function) (void *udata);
190
204
  typedef void (*duk_debug_read_flush_function) (void *udata);
191
205
  typedef void (*duk_debug_write_flush_function) (void *udata);
192
206
  typedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);
193
- typedef void (*duk_debug_detached_function) (void *udata);
207
+ typedef void (*duk_debug_detached_function) (duk_context *ctx, void *udata);
194
208
 
195
209
  struct duk_thread_state {
196
210
  /* XXX: Enough space to hold internal suspend/resume structure.
@@ -218,29 +232,40 @@ struct duk_number_list_entry {
218
232
  duk_double_t value;
219
233
  };
220
234
 
235
+ struct duk_time_components {
236
+ duk_double_t year; /* year, e.g. 2016, Ecmascript year range */
237
+ duk_double_t month; /* month: 1-12 */
238
+ duk_double_t day; /* day: 1-31 */
239
+ duk_double_t hours; /* hour: 0-59 */
240
+ duk_double_t minutes; /* minute: 0-59 */
241
+ duk_double_t seconds; /* second: 0-59 (in POSIX time no leap second) */
242
+ duk_double_t milliseconds; /* may contain sub-millisecond fractions */
243
+ duk_double_t weekday; /* weekday: 0-6, 0=Sunday, 1=Monday, ..., 6=Saturday */
244
+ };
245
+
221
246
  /*
222
247
  * Constants
223
248
  */
224
249
 
225
250
  /* Duktape version, (major * 10000) + (minor * 100) + patch. Allows C code
226
- * to #ifdef against Duktape API version. The same value is also available
227
- * to Ecmascript code in Duktape.version. Unofficial development snapshots
228
- * have 99 for patch level (e.g. 0.10.99 would be a development version
229
- * after 0.10.0 but before the next official release).
251
+ * to #if (DUK_VERSION >= NNN) against Duktape API version. The same value
252
+ * is also available to Ecmascript code in Duktape.version. Unofficial
253
+ * development snapshots have 99 for patch level (e.g. 0.10.99 would be a
254
+ * development version after 0.10.0 but before the next official release).
230
255
  */
231
- #define DUK_VERSION 10601L
256
+ #define DUK_VERSION 20001L
232
257
 
233
258
  /* Git commit, describe, and branch for Duktape build. Useful for
234
259
  * non-official snapshot builds so that application code can easily log
235
260
  * which Duktape snapshot was used. Not available in the Ecmascript
236
261
  * environment.
237
262
  */
238
- #define DUK_GIT_COMMIT "34ac011501ccaa8b74684a6c45ed4eaca9e83517"
239
- #define DUK_GIT_DESCRIBE "v1.6.1"
240
- #define DUK_GIT_BRANCH "v1.6-maintenance"
263
+ #define DUK_GIT_COMMIT "3f5e91704aff97c754f6ef5d44aedc5e529d1b16"
264
+ #define DUK_GIT_DESCRIBE "v2.0.1"
265
+ #define DUK_GIT_BRANCH "v2.0-maintenance"
241
266
 
242
267
  /* Duktape debug protocol version used by this build. */
243
- #define DUK_DEBUG_PROTOCOL_VERSION 1
268
+ #define DUK_DEBUG_PROTOCOL_VERSION 2
244
269
 
245
270
  /* Used to represent invalid index; if caller uses this without checking,
246
271
  * this index will map to a non-existent stack entry. Also used in some
@@ -284,6 +309,7 @@ struct duk_number_list_entry {
284
309
  #define DUK_TYPE_MASK_POINTER (1 << DUK_TYPE_POINTER)
285
310
  #define DUK_TYPE_MASK_LIGHTFUNC (1 << DUK_TYPE_LIGHTFUNC)
286
311
  #define DUK_TYPE_MASK_THROW (1 << 10) /* internal flag value: throw if mask doesn't match */
312
+ #define DUK_TYPE_MASK_PROMOTE (1 << 11) /* internal flag value: promote to object if mask matches */
287
313
 
288
314
  /* Coercion hints */
289
315
  #define DUK_HINT_NONE 0 /* prefer number, unless input is a Date, in which
@@ -294,16 +320,16 @@ struct duk_number_list_entry {
294
320
 
295
321
  /* Enumeration flags for duk_enum() */
296
322
  #define DUK_ENUM_INCLUDE_NONENUMERABLE (1 << 0) /* enumerate non-numerable properties in addition to enumerable */
297
- #define DUK_ENUM_INCLUDE_INTERNAL (1 << 1) /* enumerate internal properties (regardless of enumerability) */
298
- #define DUK_ENUM_OWN_PROPERTIES_ONLY (1 << 2) /* don't walk prototype chain, only check own properties */
299
- #define DUK_ENUM_ARRAY_INDICES_ONLY (1 << 3) /* only enumerate array indices */
300
- #define DUK_ENUM_SORT_ARRAY_INDICES (1 << 4) /* sort array indices, use with DUK_ENUM_ARRAY_INDICES_ONLY */
301
- #define DUK_ENUM_NO_PROXY_BEHAVIOR (1 << 5) /* enumerate a proxy object itself without invoking proxy behavior */
323
+ #define DUK_ENUM_INCLUDE_HIDDEN (1 << 1) /* enumerate hidden symbols too (in Duktape 1.x called internal properties) */
324
+ #define DUK_ENUM_INCLUDE_SYMBOLS (1 << 2) /* enumerate symbols */
325
+ #define DUK_ENUM_EXCLUDE_STRINGS (1 << 3) /* exclude strings */
326
+ #define DUK_ENUM_OWN_PROPERTIES_ONLY (1 << 4) /* don't walk prototype chain, only check own properties */
327
+ #define DUK_ENUM_ARRAY_INDICES_ONLY (1 << 5) /* only enumerate array indices */
328
+ #define DUK_ENUM_SORT_ARRAY_INDICES (1 << 6) /* sort array indices (applied to full enumeration result, including inherited array indices) */
329
+ #define DUK_ENUM_NO_PROXY_BEHAVIOR (1 << 7) /* enumerate a proxy object itself without invoking proxy behavior */
302
330
 
303
331
  /* Compilation flags for duk_compile() and duk_eval() */
304
- /* DUK_COMPILE_xxx bits 0-2 are reserved for an internal 'nargs' argument
305
- * (the nargs value passed is direct stack arguments + 1 to account for an
306
- * internal extra argument).
332
+ /* DUK_COMPILE_xxx bits 0-2 are reserved for an internal 'nargs' argument.
307
333
  */
308
334
  #define DUK_COMPILE_EVAL (1 << 3) /* compile eval code (instead of global code) */
309
335
  #define DUK_COMPILE_FUNCTION (1 << 4) /* compile function code (instead of global code) */
@@ -335,36 +361,20 @@ struct duk_number_list_entry {
335
361
  /* Flags for duk_push_thread_raw() */
336
362
  #define DUK_THREAD_NEW_GLOBAL_ENV (1 << 0) /* create a new global environment */
337
363
 
338
- /* Flags for duk_push_string_file_raw() */
339
- #define DUK_STRING_PUSH_SAFE (1 << 0) /* no error if file does not exist */
364
+ /* Flags for duk_gc() */
365
+ #define DUK_GC_COMPACT (1 << 0) /* compact heap objects */
340
366
 
341
- /* Duktape specific error codes (must be 8 bits at most, see duk_error.h) */
367
+ /* Error codes (must be 8 bits at most, see duk_error.h) */
342
368
  #define DUK_ERR_NONE 0 /* no error (e.g. from duk_get_error_code()) */
343
- #define DUK_ERR_UNIMPLEMENTED_ERROR 50 /* UnimplementedError */ /* XXX: replace with TypeError? */
344
- #define DUK_ERR_UNSUPPORTED_ERROR 51 /* UnsupportedError */ /* XXX: replace with TypeError? */
345
- #define DUK_ERR_INTERNAL_ERROR 52 /* InternalError */ /* XXX: replace with plain Error? */
346
- #define DUK_ERR_ALLOC_ERROR 53 /* AllocError */ /* XXX: replace with RangeError? */
347
- #define DUK_ERR_ASSERTION_ERROR 54 /* AssertionError */ /* XXX: to be removed? */
348
- #define DUK_ERR_API_ERROR 55 /* APIError */ /* XXX: replace with TypeError? */
349
- #define DUK_ERR_UNCAUGHT_ERROR 56 /* UncaughtError */ /* XXX: to be removed? */
350
-
351
- /* Ecmascript E5 specification error codes */
352
- #define DUK_ERR_ERROR 100 /* Error */
353
- #define DUK_ERR_EVAL_ERROR 101 /* EvalError */
354
- #define DUK_ERR_RANGE_ERROR 102 /* RangeError */
355
- #define DUK_ERR_REFERENCE_ERROR 103 /* ReferenceError */
356
- #define DUK_ERR_SYNTAX_ERROR 104 /* SyntaxError */
357
- #define DUK_ERR_TYPE_ERROR 105 /* TypeError */
358
- #define DUK_ERR_URI_ERROR 106 /* URIError */
369
+ #define DUK_ERR_ERROR 1 /* Error */
370
+ #define DUK_ERR_EVAL_ERROR 2 /* EvalError */
371
+ #define DUK_ERR_RANGE_ERROR 3 /* RangeError */
372
+ #define DUK_ERR_REFERENCE_ERROR 4 /* ReferenceError */
373
+ #define DUK_ERR_SYNTAX_ERROR 5 /* SyntaxError */
374
+ #define DUK_ERR_TYPE_ERROR 6 /* TypeError */
375
+ #define DUK_ERR_URI_ERROR 7 /* URIError */
359
376
 
360
377
  /* Return codes for C functions (shortcut for throwing an error) */
361
- #define DUK_RET_UNIMPLEMENTED_ERROR (-DUK_ERR_UNIMPLEMENTED_ERROR)
362
- #define DUK_RET_UNSUPPORTED_ERROR (-DUK_ERR_UNSUPPORTED_ERROR)
363
- #define DUK_RET_INTERNAL_ERROR (-DUK_ERR_INTERNAL_ERROR)
364
- #define DUK_RET_ALLOC_ERROR (-DUK_ERR_ALLOC_ERROR)
365
- #define DUK_RET_ASSERTION_ERROR (-DUK_ERR_ASSERTION_ERROR)
366
- #define DUK_RET_API_ERROR (-DUK_ERR_API_ERROR)
367
- #define DUK_RET_UNCAUGHT_ERROR (-DUK_ERR_UNCAUGHT_ERROR)
368
378
  #define DUK_RET_ERROR (-DUK_ERR_ERROR)
369
379
  #define DUK_RET_EVAL_ERROR (-DUK_ERR_EVAL_ERROR)
370
380
  #define DUK_RET_RANGE_ERROR (-DUK_ERR_RANGE_ERROR)
@@ -377,20 +387,17 @@ struct duk_number_list_entry {
377
387
  #define DUK_EXEC_SUCCESS 0
378
388
  #define DUK_EXEC_ERROR 1
379
389
 
380
- /* Log levels */
381
- #define DUK_LOG_TRACE 0
382
- #define DUK_LOG_DEBUG 1
383
- #define DUK_LOG_INFO 2
384
- #define DUK_LOG_WARN 3
385
- #define DUK_LOG_ERROR 4
386
- #define DUK_LOG_FATAL 5
390
+ /* Debug levels for DUK_USE_DEBUG_WRITE(). */
391
+ #define DUK_LEVEL_DEBUG 0
392
+ #define DUK_LEVEL_DDEBUG 1
393
+ #define DUK_LEVEL_DDDEBUG 2
387
394
 
388
395
  /*
389
396
  * If no variadic macros, __FILE__ and __LINE__ are passed through globals
390
397
  * which is ugly and not thread safe.
391
398
  */
392
399
 
393
- #ifndef DUK_API_VARIADIC_MACROS
400
+ #if !defined(DUK_API_VARIADIC_MACROS)
394
401
  DUK_EXTERNAL_DECL const char *duk_api_global_filename;
395
402
  DUK_EXTERNAL_DECL duk_int_t duk_api_global_line;
396
403
  #endif
@@ -432,29 +439,99 @@ DUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);
432
439
  * Error handling
433
440
  */
434
441
 
435
- DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw(duk_context *ctx));
436
- DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg));
442
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw_raw(duk_context *ctx));
443
+ #define duk_throw(ctx) \
444
+ (duk_throw_raw((ctx)), (duk_ret_t) 0)
445
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal_raw(duk_context *ctx, const char *err_msg));
446
+ #define duk_fatal(ctx,err_msg) \
447
+ (duk_fatal_raw((ctx), (err_msg)), (duk_ret_t) 0)
437
448
 
449
+ #if defined(DUK_API_VARIADIC_MACROS)
438
450
  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, ...));
439
-
440
- #ifdef DUK_API_VARIADIC_MACROS
441
451
  #define duk_error(ctx,err_code,...) \
442
- duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
443
- #else
444
- DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
445
- /* One problem with this macro is that expressions like the following fail
446
- * to compile: "(void) duk_error(...)". But because duk_error() is noreturn,
447
- * they make little sense anyway.
448
- */
452
+ (duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
453
+ #define duk_generic_error(ctx,...) \
454
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
455
+ #define duk_eval_error(ctx,...) \
456
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
457
+ #define duk_range_error(ctx,...) \
458
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
459
+ #define duk_reference_error(ctx,...) \
460
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
461
+ #define duk_syntax_error(ctx,...) \
462
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
463
+ #define duk_type_error(ctx,...) \
464
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
465
+ #define duk_uri_error(ctx,...) \
466
+ (duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)
467
+ #else /* DUK_API_VARIADIC_MACROS */
468
+ /* For legacy compilers without variadic macros a macro hack is used to allow
469
+ * variable arguments. While the macro allows "return duk_error(...)", it
470
+ * will fail with e.g. "(void) duk_error(...)". The calls are noreturn but
471
+ * with a return value to allow the "return duk_error(...)" idiom. This may
472
+ * cause some compiler warnings, but without noreturn the generated code is
473
+ * often worse. The same approach as with variadic macros (using
474
+ * "(duk_error(...), 0)") won't work due to the macro hack structure.
475
+ */
476
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
477
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_generic_error_stash(duk_context *ctx, const char *fmt, ...));
478
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_eval_error_stash(duk_context *ctx, const char *fmt, ...));
479
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_range_error_stash(duk_context *ctx, const char *fmt, ...));
480
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_reference_error_stash(duk_context *ctx, const char *fmt, ...));
481
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_syntax_error_stash(duk_context *ctx, const char *fmt, ...));
482
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_type_error_stash(duk_context *ctx, const char *fmt, ...));
483
+ DUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_uri_error_stash(duk_context *ctx, const char *fmt, ...));
449
484
  #define duk_error \
450
485
  (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
451
486
  duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
452
487
  duk_error_stash) /* last value is func pointer, arguments follow in parens */
453
- #endif
488
+ #define duk_generic_error \
489
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
490
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
491
+ duk_generic_error_stash)
492
+ #define duk_eval_error \
493
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
494
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
495
+ duk_eval_error_stash)
496
+ #define duk_range_error \
497
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
498
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
499
+ duk_range_error_stash)
500
+ #define duk_reference_error \
501
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
502
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
503
+ duk_reference_error_stash)
504
+ #define duk_syntax_error \
505
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
506
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
507
+ duk_syntax_error_stash)
508
+ #define duk_type_error \
509
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
510
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
511
+ duk_type_error_stash)
512
+ #define duk_uri_error \
513
+ (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
514
+ duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
515
+ duk_uri_error_stash)
516
+ #endif /* DUK_API_VARIADIC_MACROS */
454
517
 
455
518
  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));
456
519
  #define duk_error_va(ctx,err_code,fmt,ap) \
457
- duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
520
+ (duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
521
+ #define duk_generic_error_va(ctx,fmt,ap) \
522
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
523
+ #define duk_eval_error_va(ctx,fmt,ap) \
524
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
525
+ #define duk_range_error_va(ctx,fmt,ap) \
526
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
527
+ #define duk_reference_error_va(ctx,fmt,ap) \
528
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
529
+ #define duk_syntax_error_va(ctx,fmt,ap) \
530
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
531
+ #define duk_type_error_va(ctx,fmt,ap) \
532
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
533
+ #define duk_uri_error_va(ctx,fmt,ap) \
534
+ (duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)
458
535
 
459
536
  /*
460
537
  * Other state related functions
@@ -467,13 +544,13 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);
467
544
  * Stack management
468
545
  */
469
546
 
470
- DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index);
471
- DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index);
472
- DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index);
473
- DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t index);
547
+ DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx);
548
+ DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx);
549
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx);
550
+ DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx);
474
551
 
475
552
  DUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);
476
- DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t index);
553
+ DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t idx);
477
554
  DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);
478
555
  DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);
479
556
 
@@ -493,14 +570,14 @@ DUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);
493
570
  * Stack manipulation (other than push/pop)
494
571
  */
495
572
 
496
- DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
497
- DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t index);
498
- DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_index);
573
+ DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
574
+ DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);
575
+ DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);
499
576
  DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);
500
- DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_index);
501
- DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_index);
502
- DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index);
503
- DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t index);
577
+ DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);
578
+ DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);
579
+ DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);
580
+ DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);
504
581
  DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);
505
582
 
506
583
  #define duk_xmove_top(to_ctx,from_ctx,count) \
@@ -532,10 +609,6 @@ DUK_EXTERNAL_DECL void duk_push_pointer(duk_context *ctx, void *p);
532
609
  DUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);
533
610
  DUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);
534
611
 
535
- DUK_EXTERNAL_DECL const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags);
536
- #define duk_push_string_file(ctx,path) \
537
- duk_push_string_file_raw((ctx), (path), 0)
538
-
539
612
  DUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx);
540
613
  DUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx);
541
614
  DUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx);
@@ -545,6 +618,7 @@ DUK_EXTERNAL_DECL void duk_push_global_stash(duk_context *ctx);
545
618
  DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);
546
619
 
547
620
  DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);
621
+ DUK_EXTERNAL_DECL duk_idx_t duk_push_bare_object(duk_context *ctx);
548
622
  DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);
549
623
  DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);
550
624
  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);
@@ -558,7 +632,7 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t fla
558
632
 
559
633
  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, ...);
560
634
 
561
- #ifdef DUK_API_VARIADIC_MACROS
635
+ #if defined(DUK_API_VARIADIC_MACROS)
562
636
  #define duk_push_error_object(ctx,err_code,...) \
563
637
  duk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
564
638
  #else
@@ -590,19 +664,18 @@ DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, d
590
664
  ((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))
591
665
 
592
666
  #define DUK_BUFOBJ_CREATE_ARRBUF (1 << 4) /* internal flag: create backing ArrayBuffer; keep in one byte */
593
- #define DUK_BUFOBJ_DUKTAPE_BUFFER 0
594
- #define DUK_BUFOBJ_NODEJS_BUFFER 1
595
- #define DUK_BUFOBJ_ARRAYBUFFER 2
596
- #define DUK_BUFOBJ_DATAVIEW (3 | DUK_BUFOBJ_CREATE_ARRBUF)
597
- #define DUK_BUFOBJ_INT8ARRAY (4 | DUK_BUFOBJ_CREATE_ARRBUF)
598
- #define DUK_BUFOBJ_UINT8ARRAY (5 | DUK_BUFOBJ_CREATE_ARRBUF)
599
- #define DUK_BUFOBJ_UINT8CLAMPEDARRAY (6 | DUK_BUFOBJ_CREATE_ARRBUF)
600
- #define DUK_BUFOBJ_INT16ARRAY (7 | DUK_BUFOBJ_CREATE_ARRBUF)
601
- #define DUK_BUFOBJ_UINT16ARRAY (8 | DUK_BUFOBJ_CREATE_ARRBUF)
602
- #define DUK_BUFOBJ_INT32ARRAY (9 | DUK_BUFOBJ_CREATE_ARRBUF)
603
- #define DUK_BUFOBJ_UINT32ARRAY (10 | DUK_BUFOBJ_CREATE_ARRBUF)
604
- #define DUK_BUFOBJ_FLOAT32ARRAY (11 | DUK_BUFOBJ_CREATE_ARRBUF)
605
- #define DUK_BUFOBJ_FLOAT64ARRAY (12 | DUK_BUFOBJ_CREATE_ARRBUF)
667
+ #define DUK_BUFOBJ_ARRAYBUFFER 0
668
+ #define DUK_BUFOBJ_NODEJS_BUFFER (1 | DUK_BUFOBJ_CREATE_ARRBUF)
669
+ #define DUK_BUFOBJ_DATAVIEW (2 | DUK_BUFOBJ_CREATE_ARRBUF)
670
+ #define DUK_BUFOBJ_INT8ARRAY (3 | DUK_BUFOBJ_CREATE_ARRBUF)
671
+ #define DUK_BUFOBJ_UINT8ARRAY (4 | DUK_BUFOBJ_CREATE_ARRBUF)
672
+ #define DUK_BUFOBJ_UINT8CLAMPEDARRAY (5 | DUK_BUFOBJ_CREATE_ARRBUF)
673
+ #define DUK_BUFOBJ_INT16ARRAY (6 | DUK_BUFOBJ_CREATE_ARRBUF)
674
+ #define DUK_BUFOBJ_UINT16ARRAY (7 | DUK_BUFOBJ_CREATE_ARRBUF)
675
+ #define DUK_BUFOBJ_INT32ARRAY (8 | DUK_BUFOBJ_CREATE_ARRBUF)
676
+ #define DUK_BUFOBJ_UINT32ARRAY (9 | DUK_BUFOBJ_CREATE_ARRBUF)
677
+ #define DUK_BUFOBJ_FLOAT32ARRAY (10 | DUK_BUFOBJ_CREATE_ARRBUF)
678
+ #define DUK_BUFOBJ_FLOAT64ARRAY (11 | DUK_BUFOBJ_CREATE_ARRBUF)
606
679
 
607
680
  DUK_EXTERNAL_DECL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags);
608
681
 
@@ -624,70 +697,77 @@ DUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);
624
697
  * is not needed; duk_is_valid_index() gives the same information.
625
698
  */
626
699
 
627
- DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index);
628
- DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type);
629
- DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index);
630
- DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask);
631
-
632
- DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index);
633
- DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index);
634
- DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index);
635
- DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index);
636
- DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index);
637
- DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t index);
638
- DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index);
639
- DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index);
640
- DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index);
641
- DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index);
642
- DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index);
643
-
644
- DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index);
645
- DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index);
646
- DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t index);
647
- DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t index);
648
- DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t index);
649
- DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
650
-
651
- #define duk_is_callable(ctx,index) \
652
- duk_is_function((ctx), (index))
653
- DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t index);
654
- DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t index);
655
- DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t index);
656
-
657
- #define duk_is_primitive(ctx,index) \
658
- duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_UNDEFINED | \
659
- DUK_TYPE_MASK_NULL | \
660
- DUK_TYPE_MASK_BOOLEAN | \
661
- DUK_TYPE_MASK_NUMBER | \
662
- DUK_TYPE_MASK_STRING | \
663
- DUK_TYPE_MASK_BUFFER | \
664
- DUK_TYPE_MASK_POINTER | \
665
- DUK_TYPE_MASK_LIGHTFUNC)
666
-
667
- #define duk_is_object_coercible(ctx,index) \
668
- duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
669
- DUK_TYPE_MASK_NUMBER | \
670
- DUK_TYPE_MASK_STRING | \
671
- DUK_TYPE_MASK_OBJECT | \
672
- DUK_TYPE_MASK_BUFFER | \
673
- DUK_TYPE_MASK_POINTER | \
674
- DUK_TYPE_MASK_LIGHTFUNC)
675
-
676
- DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index);
677
- #define duk_is_error(ctx,index) \
678
- (duk_get_error_code((ctx), (index)) != 0)
679
- #define duk_is_eval_error(ctx,index) \
680
- (duk_get_error_code((ctx), (index)) == DUK_ERR_EVAL_ERROR)
681
- #define duk_is_range_error(ctx,index) \
682
- (duk_get_error_code((ctx), (index)) == DUK_ERR_RANGE_ERROR)
683
- #define duk_is_reference_error(ctx,index) \
684
- (duk_get_error_code((ctx), (index)) == DUK_ERR_REFERENCE_ERROR)
685
- #define duk_is_syntax_error(ctx,index) \
686
- (duk_get_error_code((ctx), (index)) == DUK_ERR_SYNTAX_ERROR)
687
- #define duk_is_type_error(ctx,index) \
688
- (duk_get_error_code((ctx), (index)) == DUK_ERR_TYPE_ERROR)
689
- #define duk_is_uri_error(ctx,index) \
690
- (duk_get_error_code((ctx), (index)) == DUK_ERR_URI_ERROR)
700
+ DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx);
701
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type);
702
+ DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx);
703
+ DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask);
704
+
705
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx);
706
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx);
707
+ #define duk_is_null_or_undefined(ctx, idx) \
708
+ ((duk_get_type_mask((ctx), (idx)) & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) ? 1 : 0)
709
+
710
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx);
711
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx);
712
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx);
713
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx);
714
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx);
715
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx);
716
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx);
717
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx);
718
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx);
719
+
720
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_symbol(duk_context *ctx, duk_idx_t idx);
721
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx);
722
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx);
723
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx);
724
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx);
725
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx);
726
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx);
727
+
728
+ #define duk_is_callable(ctx,idx) \
729
+ duk_is_function((ctx), (idx))
730
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx);
731
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx);
732
+ DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx);
733
+
734
+ /* Buffers and lightfuncs are not considered primitive because they mimic
735
+ * objects and e.g. duk_to_primitive() will coerce them instead of returning
736
+ * them as is. Symbols are represented as strings internally.
737
+ */
738
+ #define duk_is_primitive(ctx,idx) \
739
+ duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_UNDEFINED | \
740
+ DUK_TYPE_MASK_NULL | \
741
+ DUK_TYPE_MASK_BOOLEAN | \
742
+ DUK_TYPE_MASK_NUMBER | \
743
+ DUK_TYPE_MASK_STRING | \
744
+ DUK_TYPE_MASK_POINTER)
745
+
746
+ /* Symbols are object coercible, covered by DUK_TYPE_MASK_STRING. */
747
+ #define duk_is_object_coercible(ctx,idx) \
748
+ duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \
749
+ DUK_TYPE_MASK_NUMBER | \
750
+ DUK_TYPE_MASK_STRING | \
751
+ DUK_TYPE_MASK_OBJECT | \
752
+ DUK_TYPE_MASK_BUFFER | \
753
+ DUK_TYPE_MASK_POINTER | \
754
+ DUK_TYPE_MASK_LIGHTFUNC)
755
+
756
+ DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);
757
+ #define duk_is_error(ctx,idx) \
758
+ (duk_get_error_code((ctx), (idx)) != 0)
759
+ #define duk_is_eval_error(ctx,idx) \
760
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_EVAL_ERROR)
761
+ #define duk_is_range_error(ctx,idx) \
762
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_RANGE_ERROR)
763
+ #define duk_is_reference_error(ctx,idx) \
764
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_REFERENCE_ERROR)
765
+ #define duk_is_syntax_error(ctx,idx) \
766
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_SYNTAX_ERROR)
767
+ #define duk_is_type_error(ctx,idx) \
768
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_TYPE_ERROR)
769
+ #define duk_is_uri_error(ctx,idx) \
770
+ (duk_get_error_code((ctx), (idx)) == DUK_ERR_URI_ERROR)
691
771
 
692
772
  /*
693
773
  * Get operations: no coercion, returns default value for invalid
@@ -697,48 +777,50 @@ DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t i
697
777
  * are not included.
698
778
  */
699
779
 
700
- DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t index);
701
- DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index);
702
- DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t index);
703
- DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t index);
704
- DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t index);
705
- DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
706
- DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
707
- DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
708
- DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t index);
709
- DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index);
710
- DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t index);
711
- DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t index);
712
- DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
780
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx);
781
+ DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx);
782
+ DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx);
783
+ DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx);
784
+ DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t idx);
785
+ DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
786
+ DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
787
+ DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
788
+ DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx);
789
+ DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx);
790
+ DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx);
791
+ DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx);
792
+ DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx);
793
+ DUK_EXTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t len);
713
794
 
714
795
  /*
715
796
  * Require operations: no coercion, throw error if index or type
716
797
  * is incorrect. No defaulting.
717
798
  */
718
799
 
719
- #define duk_require_type_mask(ctx,index,mask) \
720
- ((void) duk_check_type_mask((ctx), (index), (mask) | DUK_TYPE_MASK_THROW))
721
-
722
- DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t index);
723
- DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t index);
724
- DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t index);
725
- DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index);
726
- DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t index);
727
- DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index);
728
- DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t index);
729
- DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
730
- DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
731
- DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
732
- DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
733
- DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
734
- DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
735
- DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t index);
736
- #define duk_require_callable(ctx,index) \
737
- duk_require_function((ctx), (index))
738
- DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
739
-
740
- #define duk_require_object_coercible(ctx,index) \
741
- ((void) duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
800
+ #define duk_require_type_mask(ctx,idx,mask) \
801
+ ((void) duk_check_type_mask((ctx), (idx), (mask) | DUK_TYPE_MASK_THROW))
802
+
803
+ DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t idx);
804
+ DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t idx);
805
+ DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx);
806
+ DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx);
807
+ DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx);
808
+ DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx);
809
+ DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t idx);
810
+ DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
811
+ DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
812
+ DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
813
+ DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx);
814
+ DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx);
815
+ DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx);
816
+ DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);
817
+ #define duk_require_callable(ctx,idx) \
818
+ duk_require_function((ctx), (idx))
819
+ DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);
820
+
821
+ /* Symbols are object coercible and covered by DUK_TYPE_MASK_STRING. */
822
+ #define duk_require_object_coercible(ctx,idx) \
823
+ ((void) duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \
742
824
  DUK_TYPE_MASK_NUMBER | \
743
825
  DUK_TYPE_MASK_STRING | \
744
826
  DUK_TYPE_MASK_OBJECT | \
@@ -754,57 +836,58 @@ DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
754
836
  * or an internal error (e.g. from out of memory).
755
837
  */
756
838
 
757
- DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t index);
758
- DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t index);
759
- DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index);
760
- DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t index);
761
- DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t index);
762
- DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index);
763
- DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t index);
764
- DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index);
765
- DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t index);
766
- DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t index);
767
- DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
768
- DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t flags);
769
- DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t index);
770
- DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t index);
771
- DUK_EXTERNAL_DECL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint);
772
- DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint);
839
+ DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t idx);
840
+ DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t idx);
841
+ DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx);
842
+ DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx);
843
+ DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx);
844
+ DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx);
845
+ DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx);
846
+ DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx);
847
+ DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx);
848
+ DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t idx);
849
+ DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
850
+ DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t flags);
851
+ DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx);
852
+ DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t idx);
853
+ DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint);
773
854
 
774
855
  #define DUK_BUF_MODE_FIXED 0 /* internal: request fixed buffer result */
775
856
  #define DUK_BUF_MODE_DYNAMIC 1 /* internal: request dynamic buffer result */
776
857
  #define DUK_BUF_MODE_DONTCARE 2 /* internal: don't care about fixed/dynamic nature */
777
858
 
778
- #define duk_to_buffer(ctx,index,out_size) \
779
- duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)
780
- #define duk_to_fixed_buffer(ctx,index,out_size) \
781
- duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)
782
- #define duk_to_dynamic_buffer(ctx,index,out_size) \
783
- duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DYNAMIC)
859
+ #define duk_to_buffer(ctx,idx,out_size) \
860
+ duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DONTCARE)
861
+ #define duk_to_fixed_buffer(ctx,idx,out_size) \
862
+ duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_FIXED)
863
+ #define duk_to_dynamic_buffer(ctx,idx,out_size) \
864
+ duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DYNAMIC)
784
865
 
785
866
  /* safe variants of a few coercion operations */
786
- DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
787
- #define duk_safe_to_string(ctx,index) \
788
- duk_safe_to_lstring((ctx), (index), NULL)
867
+ DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
868
+ #define duk_safe_to_string(ctx,idx) \
869
+ duk_safe_to_lstring((ctx), (idx), NULL)
789
870
 
790
871
  /*
791
872
  * Misc conversion
792
873
  */
793
874
 
794
- DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index);
795
- DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t index);
796
- DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index);
797
- DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t index);
798
- DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t index);
799
- DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t index);
875
+ DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx);
876
+ DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t idx);
877
+ DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);
878
+ DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);
879
+ DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);
880
+ DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);
881
+
882
+ DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);
800
883
 
801
884
  /*
802
885
  * Buffer
803
886
  */
804
887
 
805
- DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
806
- DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
807
- DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len);
888
+ DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size);
889
+ DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
890
+ DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len);
808
891
 
809
892
  /*
810
893
  * Property access
@@ -814,36 +897,51 @@ DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void
814
897
  * index as a property name (e.g. 123 is equivalent to the key "123").
815
898
  */
816
899
 
817
- DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index);
818
- DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
819
- DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
820
- DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index);
821
- DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
822
- DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
823
- DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index);
824
- DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
825
- DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
826
- DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index);
827
- DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
828
- DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
829
- DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags);
900
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx);
901
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
902
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);
903
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
904
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx);
905
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
906
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);
907
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
908
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx);
909
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
910
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);
911
+ DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
912
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx);
913
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
914
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);
915
+ DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
916
+
917
+ DUK_EXTERNAL_DECL void duk_get_prop_desc(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);
918
+ DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);
830
919
 
831
920
  DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);
921
+ DUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);
832
922
  DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);
923
+ DUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);
924
+
925
+ /*
926
+ * Inspection
927
+ */
928
+
929
+ DUK_EXTERNAL_DECL void duk_inspect_value(duk_context *ctx, duk_idx_t idx);
930
+ DUK_EXTERNAL_DECL void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level);
833
931
 
834
932
  /*
835
933
  * Object prototype
836
934
  */
837
935
 
838
- DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t index);
839
- DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t index);
936
+ DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t idx);
937
+ DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t idx);
840
938
 
841
939
  /*
842
940
  * Object finalizer
843
941
  */
844
942
 
845
- DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t index);
846
- DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t index);
943
+ DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx);
944
+ DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx);
847
945
 
848
946
  /*
849
947
  * Global object
@@ -855,36 +953,24 @@ DUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);
855
953
  * Duktape/C function magic value
856
954
  */
857
955
 
858
- DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index);
859
- DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t index, duk_int_t magic);
956
+ DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx);
957
+ DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic);
860
958
  DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);
861
959
 
862
960
  /*
863
961
  * Module helpers: put multiple function or constant properties
864
962
  */
865
963
 
866
- DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs);
867
- DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers);
868
-
869
- /*
870
- * Variable access
871
- */
872
-
873
- /* XXX: These calls are incomplete and not usable now. They are not (yet)
874
- * part of the public API.
875
- */
876
- DUK_EXTERNAL_DECL void duk_get_var(duk_context *ctx);
877
- DUK_EXTERNAL_DECL void duk_put_var(duk_context *ctx);
878
- DUK_EXTERNAL_DECL duk_bool_t duk_del_var(duk_context *ctx);
879
- DUK_EXTERNAL_DECL duk_bool_t duk_has_var(duk_context *ctx);
964
+ DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs);
965
+ DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers);
880
966
 
881
967
  /*
882
968
  * Object operations
883
969
  */
884
970
 
885
- DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_index);
886
- DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags);
887
- DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value);
971
+ DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_idx);
972
+ DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags);
973
+ DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_idx, duk_bool_t get_value);
888
974
 
889
975
  /*
890
976
  * String manipulation
@@ -892,19 +978,20 @@ DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, du
892
978
 
893
979
  DUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);
894
980
  DUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);
895
- DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata);
896
- DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata);
897
- 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);
898
- DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t index);
899
- DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset);
981
+ DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata);
982
+ DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata);
983
+ DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset);
984
+ DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t idx);
985
+ DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);
900
986
 
901
987
  /*
902
988
  * Ecmascript operators
903
989
  */
904
990
 
905
- DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
906
- DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
907
- DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
991
+ DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
992
+ DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
993
+ DUK_EXTERNAL_DECL duk_bool_t duk_samevalue(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
994
+ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
908
995
 
909
996
  /*
910
997
  * Function (method) calls
@@ -912,13 +999,13 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1,
912
999
 
913
1000
  DUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);
914
1001
  DUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);
915
- DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
1002
+ DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
916
1003
  DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);
917
1004
  DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);
918
- DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
1005
+ DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
919
1006
  DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);
920
1007
  DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);
921
- 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);
1008
+ DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);
922
1009
 
923
1010
  /*
924
1011
  * Thread management
@@ -937,103 +1024,72 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
937
1024
 
938
1025
  /* plain */
939
1026
  #define duk_eval(ctx) \
940
- ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))
1027
+ ((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))
941
1028
 
942
1029
  #define duk_eval_noresult(ctx) \
943
- ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1030
+ ((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
944
1031
 
945
1032
  #define duk_peval(ctx) \
946
- (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
1033
+ (duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
947
1034
 
948
1035
  #define duk_peval_noresult(ctx) \
949
- (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1036
+ (duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
950
1037
 
951
1038
  #define duk_compile(ctx,flags) \
952
- ((void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
1039
+ ((void) duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags)))
953
1040
 
954
1041
  #define duk_pcompile(ctx,flags) \
955
- (duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
1042
+ (duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE))
956
1043
 
957
1044
  /* string */
958
1045
  #define duk_eval_string(ctx,src) \
959
- ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
1046
+ ((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
960
1047
 
961
1048
  #define duk_eval_string_noresult(ctx,src) \
962
- ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1049
+ ((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
963
1050
 
964
1051
  #define duk_peval_string(ctx,src) \
965
- (duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
1052
+ (duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
966
1053
 
967
1054
  #define duk_peval_string_noresult(ctx,src) \
968
- (duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1055
+ (duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
969
1056
 
970
1057
  #define duk_compile_string(ctx,flags,src) \
971
- ((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
1058
+ ((void) duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
972
1059
 
973
1060
  #define duk_compile_string_filename(ctx,flags,src) \
974
- ((void) duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
1061
+ ((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
975
1062
 
976
1063
  #define duk_pcompile_string(ctx,flags,src) \
977
- (duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
1064
+ (duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
978
1065
 
979
1066
  #define duk_pcompile_string_filename(ctx,flags,src) \
980
- (duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
1067
+ (duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
981
1068
 
982
1069
  /* lstring */
983
1070
  #define duk_eval_lstring(ctx,buf,len) \
984
- ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
1071
+ ((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
985
1072
 
986
1073
  #define duk_eval_lstring_noresult(ctx,buf,len) \
987
- ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1074
+ ((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
988
1075
 
989
1076
  #define duk_peval_lstring(ctx,buf,len) \
990
- (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
1077
+ (duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
991
1078
 
992
1079
  #define duk_peval_lstring_noresult(ctx,buf,len) \
993
- (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
1080
+ (duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
994
1081
 
995
1082
  #define duk_compile_lstring(ctx,flags,buf,len) \
996
- ((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
1083
+ ((void) duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
997
1084
 
998
1085
  #define duk_compile_lstring_filename(ctx,flags,buf,len) \
999
- ((void) duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))
1086
+ ((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))
1000
1087
 
1001
1088
  #define duk_pcompile_lstring(ctx,flags,buf,len) \
1002
- (duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
1089
+ (duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
1003
1090
 
1004
1091
  #define duk_pcompile_lstring_filename(ctx,flags,buf,len) \
1005
- (duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
1006
-
1007
- /* file */
1008
- #define duk_eval_file(ctx,path) \
1009
- ((void) duk_push_string_file_raw((ctx), (path), 0), \
1010
- (void) duk_push_string((ctx), (path)), \
1011
- (void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL))
1012
-
1013
- #define duk_eval_file_noresult(ctx,path) \
1014
- ((void) duk_push_string_file_raw((ctx), (path), 0), \
1015
- (void) duk_push_string((ctx), (path)), \
1016
- (void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
1017
-
1018
- #define duk_peval_file(ctx,path) \
1019
- ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
1020
- (void) duk_push_string((ctx), (path)), \
1021
- duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
1022
-
1023
- #define duk_peval_file_noresult(ctx,path) \
1024
- ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
1025
- (void) duk_push_string((ctx), (path)), \
1026
- duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
1027
-
1028
- #define duk_compile_file(ctx,flags,path) \
1029
- ((void) duk_push_string_file_raw((ctx), (path), 0), \
1030
- (void) duk_push_string((ctx), (path)), \
1031
- (void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
1032
-
1033
- #define duk_pcompile_file(ctx,flags,path) \
1034
- ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
1035
- (void) duk_push_string((ctx), (path)), \
1036
- duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
1092
+ (duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
1037
1093
 
1038
1094
  /*
1039
1095
  * Bytecode load/dump
@@ -1042,58 +1098,38 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
1042
1098
  DUK_EXTERNAL_DECL void duk_dump_function(duk_context *ctx);
1043
1099
  DUK_EXTERNAL_DECL void duk_load_function(duk_context *ctx);
1044
1100
 
1045
- /*
1046
- * Logging
1047
- */
1048
-
1049
- DUK_EXTERNAL_DECL void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);
1050
- DUK_EXTERNAL_DECL void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap);
1051
-
1052
1101
  /*
1053
1102
  * Debugging
1054
1103
  */
1055
1104
 
1056
1105
  DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
1057
1106
 
1058
- #if defined(DUK_USE_FILE_IO)
1059
- /* internal use */
1060
- #define duk_dump_context_filehandle(ctx,fh) \
1061
- (duk_push_context_dump((ctx)), \
1062
- DUK_FPRINTF((fh), "%s\n", duk_safe_to_string(ctx, -1)), \
1063
- duk_pop(ctx))
1064
-
1065
- /* external use */
1066
- #define duk_dump_context_stdout(ctx) \
1067
- duk_dump_context_filehandle((ctx), DUK_STDOUT)
1068
- #define duk_dump_context_stderr(ctx) \
1069
- duk_dump_context_filehandle((ctx), DUK_STDERR)
1070
- #else /* DUK_USE_FILE_IO */
1071
- #define duk_dump_context_stdout(ctx) ((void) 0)
1072
- #define duk_dump_context_stderr(ctx) ((void) 0)
1073
- #endif /* DUK_USE_FILE_IO */
1074
-
1075
1107
  /*
1076
1108
  * Debugger (debug protocol)
1077
1109
  */
1078
1110
 
1079
- #define duk_debugger_attach(ctx,read_cb,write_cb,peek_cb,read_flush_cb,write_flush_cb,detached_cb,udata) \
1080
- duk_debugger_attach_custom((ctx), (read_cb), (write_cb), (peek_cb), (read_flush_cb), (write_flush_cb), \
1081
- NULL, (detached_cb), (udata))
1082
-
1083
- DUK_EXTERNAL_DECL void duk_debugger_attach_custom(duk_context *ctx,
1084
- duk_debug_read_function read_cb,
1085
- duk_debug_write_function write_cb,
1086
- duk_debug_peek_function peek_cb,
1087
- duk_debug_read_flush_function read_flush_cb,
1088
- duk_debug_write_flush_function write_flush_cb,
1089
- duk_debug_request_function request_cb,
1090
- duk_debug_detached_function detached_cb,
1091
- void *udata);
1111
+ DUK_EXTERNAL_DECL void duk_debugger_attach(duk_context *ctx,
1112
+ duk_debug_read_function read_cb,
1113
+ duk_debug_write_function write_cb,
1114
+ duk_debug_peek_function peek_cb,
1115
+ duk_debug_read_flush_function read_flush_cb,
1116
+ duk_debug_write_flush_function write_flush_cb,
1117
+ duk_debug_request_function request_cb,
1118
+ duk_debug_detached_function detached_cb,
1119
+ void *udata);
1092
1120
  DUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);
1093
1121
  DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);
1094
1122
  DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues);
1095
1123
  DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
1096
1124
 
1125
+ /*
1126
+ * Time handling
1127
+ */
1128
+
1129
+ DUK_EXTERNAL_DECL duk_double_t duk_get_now(duk_context *ctx);
1130
+ DUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp);
1131
+ DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp);
1132
+
1097
1133
  /*
1098
1134
  * Date provider related constants
1099
1135
  *
@@ -1130,7 +1166,7 @@ DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
1130
1166
  * depend on the specific ordering, so change with care. 16 bits are not
1131
1167
  * enough for all parts (year, specifically).
1132
1168
  *
1133
- * (Must be in-sync with genbuiltins.py.)
1169
+ * Must be in-sync with genbuiltins.py.
1134
1170
  */
1135
1171
  #define DUK_DATE_IDX_YEAR 0 /* year */
1136
1172
  #define DUK_DATE_IDX_MONTH 1 /* month: 0 to 11 */
@@ -1142,7 +1178,7 @@ DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
1142
1178
  #define DUK_DATE_IDX_WEEKDAY 7 /* weekday: 0 to 6, 0=sunday, 1=monday, etc */
1143
1179
  #define DUK_DATE_IDX_NUM_PARTS 8
1144
1180
 
1145
- /* Internal API call flags, used for various functions in this file.
1181
+ /* Internal API call flags, used for various functions in duk_bi_date.c.
1146
1182
  * Certain flags are used by only certain functions, but since the flags
1147
1183
  * don't overlap, a single flags value can be passed around to multiple
1148
1184
  * functions.
@@ -1150,7 +1186,7 @@ DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
1150
1186
  * The unused top bits of the flags field are also used to pass values
1151
1187
  * to helpers (duk__get_part_helper() and duk__set_part_helper()).
1152
1188
  *
1153
- * (Must be in-sync with genbuiltins.py.)
1189
+ * Must be in-sync with genbuiltins.py.
1154
1190
  */
1155
1191
 
1156
1192
  /* NOTE: when writing a Date provider you only need a few specific
@@ -1187,7 +1223,7 @@ DUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];
1187
1223
  * C++ name mangling
1188
1224
  */
1189
1225
 
1190
- #ifdef __cplusplus
1226
+ #if defined(__cplusplus)
1191
1227
  /* end 'extern "C"' wrapper */
1192
1228
  }
1193
1229
  #endif
@@ -1248,7 +1284,7 @@ DUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];
1248
1284
  * duk_tval values. See: misc/clang_aliasing.c.
1249
1285
  */
1250
1286
 
1251
- #ifndef DUK_DBLUNION_H_INCLUDED
1287
+ #if !defined(DUK_DBLUNION_H_INCLUDED)
1252
1288
  #define DUK_DBLUNION_H_INCLUDED
1253
1289
 
1254
1290
  /*
@@ -1276,7 +1312,7 @@ typedef union duk_double_union duk_double_union;
1276
1312
  */
1277
1313
 
1278
1314
  #if defined(DUK_USE_DOUBLE_LE)
1279
- #ifdef DUK_USE_64BIT_OPS
1315
+ #if defined(DUK_USE_64BIT_OPS)
1280
1316
  #define DUK_DBL_IDX_ULL0 0
1281
1317
  #endif
1282
1318
  #define DUK_DBL_IDX_UI0 1
@@ -1296,7 +1332,7 @@ typedef union duk_double_union duk_double_union;
1296
1332
  #define DUK_DBL_IDX_VP0 DUK_DBL_IDX_UI0 /* packed tval */
1297
1333
  #define DUK_DBL_IDX_VP1 DUK_DBL_IDX_UI1 /* packed tval */
1298
1334
  #elif defined(DUK_USE_DOUBLE_BE)
1299
- #ifdef DUK_USE_64BIT_OPS
1335
+ #if defined(DUK_USE_64BIT_OPS)
1300
1336
  #define DUK_DBL_IDX_ULL0 0
1301
1337
  #endif
1302
1338
  #define DUK_DBL_IDX_UI0 0
@@ -1316,7 +1352,7 @@ typedef union duk_double_union duk_double_union;
1316
1352
  #define DUK_DBL_IDX_VP0 DUK_DBL_IDX_UI0 /* packed tval */
1317
1353
  #define DUK_DBL_IDX_VP1 DUK_DBL_IDX_UI1 /* packed tval */
1318
1354
  #elif defined(DUK_USE_DOUBLE_ME)
1319
- #ifdef DUK_USE_64BIT_OPS
1355
+ #if defined(DUK_USE_64BIT_OPS)
1320
1356
  #define DUK_DBL_IDX_ULL0 0 /* not directly applicable, byte order differs from a double */
1321
1357
  #endif
1322
1358
  #define DUK_DBL_IDX_UI0 0
@@ -1352,8 +1388,8 @@ typedef union duk_double_union duk_double_union;
1352
1388
  (u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \
1353
1389
  } while (0)
1354
1390
 
1355
- #ifdef DUK_USE_64BIT_OPS
1356
- #ifdef DUK_USE_DOUBLE_ME
1391
+ #if defined(DUK_USE_64BIT_OPS)
1392
+ #if defined(DUK_USE_DOUBLE_ME)
1357
1393
  #define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v) do { \
1358
1394
  (u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \
1359
1395
  } while (0)
@@ -1377,8 +1413,8 @@ typedef union duk_double_union duk_double_union;
1377
1413
  #define DUK_DBLUNION_GET_HIGH32(u) ((u)->ui[DUK_DBL_IDX_UI0])
1378
1414
  #define DUK_DBLUNION_GET_LOW32(u) ((u)->ui[DUK_DBL_IDX_UI1])
1379
1415
 
1380
- #ifdef DUK_USE_64BIT_OPS
1381
- #ifdef DUK_USE_DOUBLE_ME
1416
+ #if defined(DUK_USE_64BIT_OPS)
1417
+ #if defined(DUK_USE_DOUBLE_ME)
1382
1418
  #define DUK_DBLUNION_SET_UINT64(u,v) do { \
1383
1419
  (u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) ((v) >> 32); \
1384
1420
  (u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \
@@ -1418,70 +1454,98 @@ typedef union duk_double_union duk_double_union;
1418
1454
  * feature that while doubles have a mixed byte order (32107654), unsigned
1419
1455
  * long long values has a little endian byte order (76543210). When writing
1420
1456
  * a logical double value through a ULL pointer, the 32-bit words need to be
1421
- * swapped; hence the #ifdefs below for ULL writes with DUK_USE_DOUBLE_ME.
1457
+ * swapped; hence the #if defined()s below for ULL writes with DUK_USE_DOUBLE_ME.
1422
1458
  * This is not full ARM support but suffices for some environments.
1423
1459
  */
1424
1460
 
1425
- #ifdef DUK_USE_64BIT_OPS
1426
- #ifdef DUK_USE_DOUBLE_ME
1461
+ #if defined(DUK_USE_64BIT_OPS)
1462
+ #if defined(DUK_USE_DOUBLE_ME)
1463
+ /* Macros for 64-bit ops + mixed endian doubles. */
1427
1464
  #define DUK__DBLUNION_SET_NAN_FULL(u) do { \
1428
1465
  (u)->ull[DUK_DBL_IDX_ULL0] = 0x000000007ff80000ULL; \
1429
1466
  } while (0)
1467
+ #define DUK__DBLUNION_IS_NAN_FULL(u) \
1468
+ ((((u)->ull[DUK_DBL_IDX_ULL0] & 0x000000007ff00000ULL) == 0x000000007ff00000ULL) && \
1469
+ ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0xffffffff000fffffULL) != 0))
1470
+ #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1471
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff80000ULL)
1472
+ #define DUK__DBLUNION_IS_ANYINF(u) \
1473
+ (((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x000000007ff00000ULL)
1474
+ #define DUK__DBLUNION_IS_POSINF(u) \
1475
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff00000ULL)
1476
+ #define DUK__DBLUNION_IS_NEGINF(u) \
1477
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x00000000fff00000ULL)
1478
+ #define DUK__DBLUNION_IS_ANYZERO(u) \
1479
+ (((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x0000000000000000ULL)
1480
+ #define DUK__DBLUNION_IS_POSZERO(u) \
1481
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)
1482
+ #define DUK__DBLUNION_IS_NEGZERO(u) \
1483
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000080000000ULL)
1430
1484
  #else
1485
+ /* Macros for 64-bit ops + big/little endian doubles. */
1431
1486
  #define DUK__DBLUNION_SET_NAN_FULL(u) do { \
1432
1487
  (u)->ull[DUK_DBL_IDX_ULL0] = 0x7ff8000000000000ULL; \
1433
1488
  } while (0)
1489
+ #define DUK__DBLUNION_IS_NAN_FULL(u) \
1490
+ ((((u)->ull[DUK_DBL_IDX_ULL0] & 0x7ff0000000000000ULL) == 0x7ff0000000000000UL) && \
1491
+ ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0x000fffffffffffffULL) != 0))
1492
+ #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1493
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff8000000000000ULL)
1494
+ #define DUK__DBLUNION_IS_ANYINF(u) \
1495
+ (((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x7ff0000000000000ULL)
1496
+ #define DUK__DBLUNION_IS_POSINF(u) \
1497
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff0000000000000ULL)
1498
+ #define DUK__DBLUNION_IS_NEGINF(u) \
1499
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0xfff0000000000000ULL)
1500
+ #define DUK__DBLUNION_IS_ANYZERO(u) \
1501
+ (((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x0000000000000000ULL)
1502
+ #define DUK__DBLUNION_IS_POSZERO(u) \
1503
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)
1504
+ #define DUK__DBLUNION_IS_NEGZERO(u) \
1505
+ ((u)->ull[DUK_DBL_IDX_ULL0] == 0x8000000000000000ULL)
1434
1506
  #endif
1435
1507
  #else /* DUK_USE_64BIT_OPS */
1508
+ /* Macros for no 64-bit ops, any endianness. */
1436
1509
  #define DUK__DBLUNION_SET_NAN_FULL(u) do { \
1437
1510
  (u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) 0x7ff80000UL; \
1438
1511
  (u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0x00000000UL; \
1439
1512
  } while (0)
1440
- #endif /* DUK_USE_64BIT_OPS */
1441
-
1442
- #define DUK__DBLUNION_SET_NAN_NOTFULL(u) do { \
1443
- (u)->us[DUK_DBL_IDX_US0] = 0x7ff8UL; \
1444
- } while (0)
1445
-
1446
- #ifdef DUK_USE_64BIT_OPS
1447
- #ifdef DUK_USE_DOUBLE_ME
1448
- #define DUK__DBLUNION_IS_NAN_FULL(u) \
1449
- /* E == 0x7ff, F != 0 => NaN */ \
1450
- ((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \
1451
- ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0xffffffff000fffffULL) != 0))
1452
- #else
1453
- #define DUK__DBLUNION_IS_NAN_FULL(u) \
1454
- /* E == 0x7ff, F != 0 => NaN */ \
1455
- ((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \
1456
- ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0x000fffffffffffffULL) != 0))
1457
- #endif
1458
- #else /* DUK_USE_64BIT_OPS */
1459
1513
  #define DUK__DBLUNION_IS_NAN_FULL(u) \
1460
- /* E == 0x7ff, F != 0 => NaN */ \
1461
1514
  ((((u)->ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL) && \
1462
1515
  (((u)->ui[DUK_DBL_IDX_UI0] & 0x000fffffUL) != 0 || \
1463
1516
  (u)->ui[DUK_DBL_IDX_UI1] != 0))
1517
+ #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1518
+ (((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff80000UL) && \
1519
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1520
+ #define DUK__DBLUNION_IS_ANYINF(u) \
1521
+ ((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x7ff00000UL) && \
1522
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1523
+ #define DUK__DBLUNION_IS_POSINF(u) \
1524
+ (((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff00000UL) && \
1525
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1526
+ #define DUK__DBLUNION_IS_NEGINF(u) \
1527
+ (((u)->ui[DUK_DBL_IDX_UI0] == 0xfff00000UL) && \
1528
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1529
+ #define DUK__DBLUNION_IS_ANYZERO(u) \
1530
+ ((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x00000000UL) && \
1531
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1532
+ #define DUK__DBLUNION_IS_POSZERO(u) \
1533
+ (((u)->ui[DUK_DBL_IDX_UI0] == 0x00000000UL) && \
1534
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1535
+ #define DUK__DBLUNION_IS_NEGZERO(u) \
1536
+ (((u)->ui[DUK_DBL_IDX_UI0] == 0x80000000UL) && \
1537
+ ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1464
1538
  #endif /* DUK_USE_64BIT_OPS */
1465
1539
 
1540
+ #define DUK__DBLUNION_SET_NAN_NOTFULL(u) do { \
1541
+ (u)->us[DUK_DBL_IDX_US0] = 0x7ff8UL; \
1542
+ } while (0)
1543
+
1466
1544
  #define DUK__DBLUNION_IS_NAN_NOTFULL(u) \
1467
1545
  /* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \
1468
1546
  ((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \
1469
1547
  (((u)->us[DUK_DBL_IDX_US0] & 0x000fUL) != 0x0000UL))
1470
1548
 
1471
- #ifdef DUK_USE_64BIT_OPS
1472
- #ifdef DUK_USE_DOUBLE_ME
1473
- #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1474
- ((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff80000ULL)
1475
- #else
1476
- #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1477
- ((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff8000000000000ULL)
1478
- #endif
1479
- #else /* DUK_USE_64BIT_OPS */
1480
- #define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \
1481
- (((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff80000UL) && \
1482
- ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))
1483
- #endif /* DUK_USE_64BIT_OPS */
1484
-
1485
1549
  #define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL(u) \
1486
1550
  /* E == 0x7ff, F == 8 => normalized NaN */ \
1487
1551
  ((u)->us[DUK_DBL_IDX_US0] == 0x7ff8UL)
@@ -1521,8 +1585,8 @@ typedef union duk_double_union duk_double_union;
1521
1585
  DUK_DBLUNION_IS_NORMALIZED_NAN((u))) /* or is a normalized NaN */
1522
1586
  #else /* DUK_USE_PACKED_TVAL */
1523
1587
  #define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u) /* nop: no need to normalize */
1524
- #define DUK_DBLUNION_IS_NAN(u) (DUK_ISNAN((u)->d))
1525
- #define DUK_DBLUNION_IS_NORMALIZED_NAN(u) (DUK_ISNAN((u)->d))
1588
+ #define DUK_DBLUNION_IS_NAN(u) DUK__DBLUNION_IS_NAN_FULL((u)) /* (DUK_ISNAN((u)->d)) */
1589
+ #define DUK_DBLUNION_IS_NORMALIZED_NAN(u) DUK__DBLUNION_IS_NAN_FULL((u)) /* (DUK_ISNAN((u)->d)) */
1526
1590
  #define DUK_DBLUNION_IS_NORMALIZED(u) 1 /* all doubles are considered normalized */
1527
1591
  #define DUK_DBLUNION_SET_NAN(u) do { \
1528
1592
  /* in non-packed representation we don't care about which NaN is used */ \
@@ -1530,6 +1594,14 @@ typedef union duk_double_union duk_double_union;
1530
1594
  } while (0)
1531
1595
  #endif /* DUK_USE_PACKED_TVAL */
1532
1596
 
1597
+ #define DUK_DBLUNION_IS_ANYINF(u) DUK__DBLUNION_IS_ANYINF((u))
1598
+ #define DUK_DBLUNION_IS_POSINF(u) DUK__DBLUNION_IS_POSINF((u))
1599
+ #define DUK_DBLUNION_IS_NEGINF(u) DUK__DBLUNION_IS_NEGINF((u))
1600
+
1601
+ #define DUK_DBLUNION_IS_ANYZERO(u) DUK__DBLUNION_IS_ANYZERO((u))
1602
+ #define DUK_DBLUNION_IS_POSZERO(u) DUK__DBLUNION_IS_POSZERO((u))
1603
+ #define DUK_DBLUNION_IS_NEGZERO(u) DUK__DBLUNION_IS_NEGZERO((u))
1604
+
1533
1605
  /* XXX: native 64-bit byteswaps when available */
1534
1606
 
1535
1607
  /* 64-bit byteswap, same operation independent of target endianness. */
@@ -1575,6 +1647,15 @@ typedef union duk_double_union duk_double_union;
1575
1647
  /* Reverse operation is the same. */
1576
1648
  #define DUK_DBLUNION_DOUBLE_NTOH(u) DUK_DBLUNION_DOUBLE_HTON((u))
1577
1649
 
1650
+ /* Some sign bit helpers. */
1651
+ #if defined(DUK_USE_64BIT_OPS)
1652
+ #define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] & 0x8000000000000000ULL) != 0)
1653
+ #define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] >> 63U))
1654
+ #else
1655
+ #define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] & 0x80000000UL) != 0)
1656
+ #define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] >> 31U))
1657
+ #endif
1658
+
1578
1659
  #endif /* DUK_DBLUNION_H_INCLUDED */
1579
1660
 
1580
1661
  #endif /* DUKTAPE_H_INCLUDED */