duktape 1.3.0.6 → 1.6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/duktape/duk_config.h +2473 -1910
- data/ext/duktape/duktape.c +16726 -10303
- data/ext/duktape/duktape.h +146 -90
- data/lib/duktape/version.rb +1 -1
- metadata +3 -3
data/ext/duktape/duktape.h
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
/*
|
2
|
-
* Duktape public API for Duktape 1.
|
2
|
+
* Duktape public API for Duktape 1.6.1.
|
3
|
+
*
|
3
4
|
* See the API reference for documentation on call semantics.
|
4
5
|
* The exposed API is inside the DUK_API_PUBLIC_H_INCLUDED
|
5
6
|
* include guard. Other parts of the header are Duktape
|
6
7
|
* internal and related to platform/compiler/feature detection.
|
7
8
|
*
|
8
|
-
* Git commit
|
9
|
+
* Git commit 34ac011501ccaa8b74684a6c45ed4eaca9e83517 (v1.6.1).
|
10
|
+
* Git branch v1.6-maintenance.
|
9
11
|
*
|
10
12
|
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
|
11
13
|
* licensing information.
|
@@ -19,7 +21,7 @@
|
|
19
21
|
*
|
20
22
|
* (http://opensource.org/licenses/MIT)
|
21
23
|
*
|
22
|
-
* Copyright (c) 2013-
|
24
|
+
* Copyright (c) 2013-2016 by Duktape authors (see AUTHORS.rst)
|
23
25
|
*
|
24
26
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
25
27
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -70,6 +72,9 @@
|
|
70
72
|
* * Legimet <legimet.calc@gmail.com>
|
71
73
|
* * Karl Skomski <karl@skomski.com>
|
72
74
|
* * Bruce Pascoe <fatcerberus1@gmail.com>
|
75
|
+
* * Ren\u00e9 Hollander <rene@rene8888.at>
|
76
|
+
* * Julien Hamaide (https://github.com/crazyjul)
|
77
|
+
* * Sebastian G\u00f6tte (https://github.com/jaseg)
|
73
78
|
*
|
74
79
|
* Other contributions
|
75
80
|
* ===================
|
@@ -106,6 +111,8 @@
|
|
106
111
|
* * https://github.com/sstruchtrup
|
107
112
|
* * Michael Drake (https://github.com/tlsa)
|
108
113
|
* * https://github.com/chris-y
|
114
|
+
* * Laurent Zubiaur (https://github.com/lzubiaur)
|
115
|
+
* * Ole Andr\u00e9 Vadla Ravn\u00e5s (https://github.com/oleavr)
|
109
116
|
*
|
110
117
|
* If you are accidentally missing from this list, send me an e-mail
|
111
118
|
* (``sami.vaarala@iki.fi``) and I'll fix the omission.
|
@@ -156,6 +163,7 @@ extern "C" {
|
|
156
163
|
* in Duktape web documentation.
|
157
164
|
*/
|
158
165
|
|
166
|
+
struct duk_thread_state;
|
159
167
|
struct duk_memory_functions;
|
160
168
|
struct duk_function_list_entry;
|
161
169
|
struct duk_number_list_entry;
|
@@ -163,6 +171,7 @@ struct duk_number_list_entry;
|
|
163
171
|
/* duk_context is now defined in duk_config.h because it may also be
|
164
172
|
* referenced there by prototypes.
|
165
173
|
*/
|
174
|
+
typedef struct duk_thread_state duk_thread_state;
|
166
175
|
typedef struct duk_memory_functions duk_memory_functions;
|
167
176
|
typedef struct duk_function_list_entry duk_function_list_entry;
|
168
177
|
typedef struct duk_number_list_entry duk_number_list_entry;
|
@@ -180,8 +189,17 @@ typedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer,
|
|
180
189
|
typedef duk_size_t (*duk_debug_peek_function) (void *udata);
|
181
190
|
typedef void (*duk_debug_read_flush_function) (void *udata);
|
182
191
|
typedef void (*duk_debug_write_flush_function) (void *udata);
|
192
|
+
typedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);
|
183
193
|
typedef void (*duk_debug_detached_function) (void *udata);
|
184
194
|
|
195
|
+
struct duk_thread_state {
|
196
|
+
/* XXX: Enough space to hold internal suspend/resume structure.
|
197
|
+
* This is rather awkward and to be fixed when the internal
|
198
|
+
* structure is visible for the public API header.
|
199
|
+
*/
|
200
|
+
char data[128];
|
201
|
+
};
|
202
|
+
|
185
203
|
struct duk_memory_functions {
|
186
204
|
duk_alloc_function alloc_func;
|
187
205
|
duk_realloc_function realloc_func;
|
@@ -210,13 +228,16 @@ struct duk_number_list_entry {
|
|
210
228
|
* have 99 for patch level (e.g. 0.10.99 would be a development version
|
211
229
|
* after 0.10.0 but before the next official release).
|
212
230
|
*/
|
213
|
-
#define DUK_VERSION
|
231
|
+
#define DUK_VERSION 10601L
|
214
232
|
|
215
|
-
/* Git describe for Duktape build. Useful for
|
216
|
-
* so that application code can easily log
|
217
|
-
* Not available in the Ecmascript
|
233
|
+
/* Git commit, describe, and branch for Duktape build. Useful for
|
234
|
+
* non-official snapshot builds so that application code can easily log
|
235
|
+
* which Duktape snapshot was used. Not available in the Ecmascript
|
236
|
+
* environment.
|
218
237
|
*/
|
219
|
-
#define
|
238
|
+
#define DUK_GIT_COMMIT "34ac011501ccaa8b74684a6c45ed4eaca9e83517"
|
239
|
+
#define DUK_GIT_DESCRIBE "v1.6.1"
|
240
|
+
#define DUK_GIT_BRANCH "v1.6-maintenance"
|
220
241
|
|
221
242
|
/* Duktape debug protocol version used by this build. */
|
222
243
|
#define DUK_DEBUG_PROTOCOL_VERSION 1
|
@@ -238,6 +259,7 @@ struct duk_number_list_entry {
|
|
238
259
|
#define DUK_API_ENTRY_STACK 64
|
239
260
|
|
240
261
|
/* Value types, used by e.g. duk_get_type() */
|
262
|
+
#define DUK_TYPE_MIN 0
|
241
263
|
#define DUK_TYPE_NONE 0 /* no value, e.g. invalid index */
|
242
264
|
#define DUK_TYPE_UNDEFINED 1 /* Ecmascript undefined */
|
243
265
|
#define DUK_TYPE_NULL 2 /* Ecmascript null */
|
@@ -248,6 +270,7 @@ struct duk_number_list_entry {
|
|
248
270
|
#define DUK_TYPE_BUFFER 7 /* fixed or dynamic, garbage collected byte buffer */
|
249
271
|
#define DUK_TYPE_POINTER 8 /* raw void pointer */
|
250
272
|
#define DUK_TYPE_LIGHTFUNC 9 /* lightweight function pointer */
|
273
|
+
#define DUK_TYPE_MAX 9
|
251
274
|
|
252
275
|
/* Value mask types, used by e.g. duk_get_type_mask() */
|
253
276
|
#define DUK_TYPE_MASK_NONE (1 << DUK_TYPE_NONE)
|
@@ -278,13 +301,18 @@ struct duk_number_list_entry {
|
|
278
301
|
#define DUK_ENUM_NO_PROXY_BEHAVIOR (1 << 5) /* enumerate a proxy object itself without invoking proxy behavior */
|
279
302
|
|
280
303
|
/* Compilation flags for duk_compile() and duk_eval() */
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
#define
|
286
|
-
#define
|
287
|
-
#define
|
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).
|
307
|
+
*/
|
308
|
+
#define DUK_COMPILE_EVAL (1 << 3) /* compile eval code (instead of global code) */
|
309
|
+
#define DUK_COMPILE_FUNCTION (1 << 4) /* compile function code (instead of global code) */
|
310
|
+
#define DUK_COMPILE_STRICT (1 << 5) /* use strict (outer) context for global, eval, or function code */
|
311
|
+
#define DUK_COMPILE_SAFE (1 << 6) /* (internal) catch compilation errors */
|
312
|
+
#define DUK_COMPILE_NORESULT (1 << 7) /* (internal) omit eval result */
|
313
|
+
#define DUK_COMPILE_NOSOURCE (1 << 8) /* (internal) no source string on stack */
|
314
|
+
#define DUK_COMPILE_STRLEN (1 << 9) /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */
|
315
|
+
#define DUK_COMPILE_NOFILENAME (1 << 10) /* (internal) no filename on stack */
|
288
316
|
|
289
317
|
/* Flags for duk_def_prop() and its variants */
|
290
318
|
#define DUK_DEFPROP_WRITABLE (1 << 0) /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */
|
@@ -297,6 +325,12 @@ struct duk_number_list_entry {
|
|
297
325
|
#define DUK_DEFPROP_HAVE_GETTER (1 << 7) /* set getter (given on value stack) */
|
298
326
|
#define DUK_DEFPROP_HAVE_SETTER (1 << 8) /* set setter (given on value stack) */
|
299
327
|
#define DUK_DEFPROP_FORCE (1 << 9) /* force change if possible, may still fail for e.g. virtual properties */
|
328
|
+
#define DUK_DEFPROP_SET_WRITABLE (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)
|
329
|
+
#define DUK_DEFPROP_CLEAR_WRITABLE DUK_DEFPROP_HAVE_WRITABLE
|
330
|
+
#define DUK_DEFPROP_SET_ENUMERABLE (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)
|
331
|
+
#define DUK_DEFPROP_CLEAR_ENUMERABLE DUK_DEFPROP_HAVE_ENUMERABLE
|
332
|
+
#define DUK_DEFPROP_SET_CONFIGURABLE (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)
|
333
|
+
#define DUK_DEFPROP_CLEAR_CONFIGURABLE DUK_DEFPROP_HAVE_CONFIGURABLE
|
300
334
|
|
301
335
|
/* Flags for duk_push_thread_raw() */
|
302
336
|
#define DUK_THREAD_NEW_GLOBAL_ENV (1 << 0) /* create a new global environment */
|
@@ -304,15 +338,15 @@ struct duk_number_list_entry {
|
|
304
338
|
/* Flags for duk_push_string_file_raw() */
|
305
339
|
#define DUK_STRING_PUSH_SAFE (1 << 0) /* no error if file does not exist */
|
306
340
|
|
307
|
-
/* Duktape specific error codes */
|
341
|
+
/* Duktape specific error codes (must be 8 bits at most, see duk_error.h) */
|
308
342
|
#define DUK_ERR_NONE 0 /* no error (e.g. from duk_get_error_code()) */
|
309
|
-
#define DUK_ERR_UNIMPLEMENTED_ERROR 50 /* UnimplementedError */
|
310
|
-
#define DUK_ERR_UNSUPPORTED_ERROR 51 /* UnsupportedError */
|
311
|
-
#define DUK_ERR_INTERNAL_ERROR 52 /* InternalError */
|
312
|
-
#define DUK_ERR_ALLOC_ERROR 53 /* AllocError */
|
313
|
-
#define DUK_ERR_ASSERTION_ERROR 54 /* AssertionError */
|
314
|
-
#define DUK_ERR_API_ERROR 55 /* APIError */
|
315
|
-
#define DUK_ERR_UNCAUGHT_ERROR 56 /* UncaughtError */
|
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? */
|
316
350
|
|
317
351
|
/* Ecmascript E5 specification error codes */
|
318
352
|
#define DUK_ERR_ERROR 100 /* Error */
|
@@ -339,7 +373,7 @@ struct duk_number_list_entry {
|
|
339
373
|
#define DUK_RET_TYPE_ERROR (-DUK_ERR_TYPE_ERROR)
|
340
374
|
#define DUK_RET_URI_ERROR (-DUK_ERR_URI_ERROR)
|
341
375
|
|
342
|
-
/* Return codes for protected calls (duk_safe_call(), duk_pcall())
|
376
|
+
/* Return codes for protected calls (duk_safe_call(), duk_pcall()) */
|
343
377
|
#define DUK_EXEC_SUCCESS 0
|
344
378
|
#define DUK_EXEC_ERROR 1
|
345
379
|
|
@@ -373,6 +407,9 @@ duk_context *duk_create_heap(duk_alloc_function alloc_func,
|
|
373
407
|
duk_fatal_function fatal_handler);
|
374
408
|
DUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);
|
375
409
|
|
410
|
+
DUK_EXTERNAL_DECL void duk_suspend(duk_context *ctx, duk_thread_state *state);
|
411
|
+
DUK_EXTERNAL_DECL void duk_resume(duk_context *ctx, const duk_thread_state *state);
|
412
|
+
|
376
413
|
#define duk_create_heap_default() \
|
377
414
|
duk_create_heap(NULL, NULL, NULL, NULL, NULL)
|
378
415
|
|
@@ -402,7 +439,7 @@ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errc
|
|
402
439
|
|
403
440
|
#ifdef DUK_API_VARIADIC_MACROS
|
404
441
|
#define duk_error(ctx,err_code,...) \
|
405
|
-
duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (
|
442
|
+
duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
|
406
443
|
#else
|
407
444
|
DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));
|
408
445
|
/* One problem with this macro is that expressions like the following fail
|
@@ -410,14 +447,14 @@ DUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_er
|
|
410
447
|
* they make little sense anyway.
|
411
448
|
*/
|
412
449
|
#define duk_error \
|
413
|
-
(duk_api_global_filename = (const char *) (
|
414
|
-
duk_api_global_line = (duk_int_t) (
|
450
|
+
(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
|
451
|
+
duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
|
415
452
|
duk_error_stash) /* last value is func pointer, arguments follow in parens */
|
416
453
|
#endif
|
417
454
|
|
418
455
|
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));
|
419
456
|
#define duk_error_va(ctx,err_code,fmt,ap) \
|
420
|
-
duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (
|
457
|
+
duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
|
421
458
|
|
422
459
|
/*
|
423
460
|
* Other state related functions
|
@@ -523,19 +560,19 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errc
|
|
523
560
|
|
524
561
|
#ifdef DUK_API_VARIADIC_MACROS
|
525
562
|
#define duk_push_error_object(ctx,err_code,...) \
|
526
|
-
duk_push_error_object_raw((ctx), (err_code), (const char *) (
|
563
|
+
duk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)
|
527
564
|
#else
|
528
565
|
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);
|
529
566
|
/* Note: parentheses are required so that the comma expression works in assignments. */
|
530
567
|
#define duk_push_error_object \
|
531
|
-
(duk_api_global_filename = (const char *) (
|
532
|
-
duk_api_global_line = (duk_int_t) (
|
568
|
+
(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
|
569
|
+
duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \
|
533
570
|
duk_push_error_object_stash) /* last value is func pointer, arguments follow in parens */
|
534
571
|
#endif
|
535
572
|
|
536
573
|
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);
|
537
574
|
#define duk_push_error_object_va(ctx,err_code,fmt,ap) \
|
538
|
-
duk_push_error_object_va_raw((ctx), (err_code), (const char *) (
|
575
|
+
duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
|
539
576
|
|
540
577
|
#define DUK_BUF_FLAG_DYNAMIC (1 << 0) /* internal flag: dynamic buffer */
|
541
578
|
#define DUK_BUF_FLAG_EXTERNAL (1 << 1) /* internal flag: external buffer */
|
@@ -544,7 +581,7 @@ DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_e
|
|
544
581
|
DUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);
|
545
582
|
|
546
583
|
#define duk_push_buffer(ctx,size,dynamic) \
|
547
|
-
duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)
|
584
|
+
duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)
|
548
585
|
#define duk_push_fixed_buffer(ctx,size) \
|
549
586
|
duk_push_buffer_raw((ctx), (size), 0 /*flags*/)
|
550
587
|
#define duk_push_dynamic_buffer(ctx,size) \
|
@@ -611,7 +648,8 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_id
|
|
611
648
|
DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t index);
|
612
649
|
DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
|
613
650
|
|
614
|
-
|
651
|
+
#define duk_is_callable(ctx,index) \
|
652
|
+
duk_is_function((ctx), (index))
|
615
653
|
DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t index);
|
616
654
|
DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t index);
|
617
655
|
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t index);
|
@@ -638,6 +676,18 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t
|
|
638
676
|
DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index);
|
639
677
|
#define duk_is_error(ctx,index) \
|
640
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)
|
641
691
|
|
642
692
|
/*
|
643
693
|
* Get operations: no coercion, returns default value for invalid
|
@@ -682,6 +732,9 @@ DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t inde
|
|
682
732
|
DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
|
683
733
|
DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
|
684
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))
|
685
738
|
DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
|
686
739
|
|
687
740
|
#define duk_require_object_coercible(ctx,index) \
|
@@ -884,119 +937,103 @@ DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_bu
|
|
884
937
|
|
885
938
|
/* plain */
|
886
939
|
#define duk_eval(ctx) \
|
887
|
-
((void)
|
888
|
-
(void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL))
|
940
|
+
((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))
|
889
941
|
|
890
942
|
#define duk_eval_noresult(ctx) \
|
891
|
-
((void)
|
892
|
-
(void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
|
943
|
+
((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
|
893
944
|
|
894
945
|
#define duk_peval(ctx) \
|
895
|
-
((
|
896
|
-
duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
|
946
|
+
(duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
|
897
947
|
|
898
948
|
#define duk_peval_noresult(ctx) \
|
899
|
-
((
|
900
|
-
duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
|
949
|
+
(duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
|
901
950
|
|
902
951
|
#define duk_compile(ctx,flags) \
|
903
|
-
((void) duk_compile_raw((ctx), NULL, 0, (flags)))
|
952
|
+
((void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
|
904
953
|
|
905
954
|
#define duk_pcompile(ctx,flags) \
|
906
|
-
(duk_compile_raw((ctx), NULL, 0, (flags) | DUK_COMPILE_SAFE))
|
955
|
+
(duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
|
907
956
|
|
908
957
|
/* string */
|
909
958
|
#define duk_eval_string(ctx,src) \
|
910
|
-
((void)
|
911
|
-
(void) duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
959
|
+
((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
|
912
960
|
|
913
961
|
#define duk_eval_string_noresult(ctx,src) \
|
914
|
-
((void)
|
915
|
-
(void) duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT))
|
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))
|
916
963
|
|
917
964
|
#define duk_peval_string(ctx,src) \
|
918
|
-
((
|
919
|
-
duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
965
|
+
(duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
|
920
966
|
|
921
967
|
#define duk_peval_string_noresult(ctx,src) \
|
922
|
-
((
|
923
|
-
duk_eval_raw((ctx), (src), 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT))
|
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))
|
924
969
|
|
925
970
|
#define duk_compile_string(ctx,flags,src) \
|
926
|
-
((void)
|
927
|
-
(void) duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
971
|
+
((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
|
928
972
|
|
929
973
|
#define duk_compile_string_filename(ctx,flags,src) \
|
930
|
-
((void) duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
974
|
+
((void) duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
931
975
|
|
932
976
|
#define duk_pcompile_string(ctx,flags,src) \
|
933
|
-
((
|
934
|
-
duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
977
|
+
(duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
|
935
978
|
|
936
979
|
#define duk_pcompile_string_filename(ctx,flags,src) \
|
937
|
-
(duk_compile_raw((ctx), (src), 0, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
980
|
+
(duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
|
938
981
|
|
939
982
|
/* lstring */
|
940
983
|
#define duk_eval_lstring(ctx,buf,len) \
|
941
|
-
((void)
|
942
|
-
(void) duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE))
|
984
|
+
((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
|
943
985
|
|
944
986
|
#define duk_eval_lstring_noresult(ctx,buf,len) \
|
945
|
-
((void)
|
946
|
-
(void) duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT))
|
987
|
+
((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
|
947
988
|
|
948
989
|
#define duk_peval_lstring(ctx,buf,len) \
|
949
|
-
((
|
950
|
-
duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE))
|
990
|
+
(duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
|
951
991
|
|
952
992
|
#define duk_peval_lstring_noresult(ctx,buf,len) \
|
953
|
-
((
|
954
|
-
duk_eval_raw((ctx), buf, len, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT))
|
993
|
+
(duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
|
955
994
|
|
956
995
|
#define duk_compile_lstring(ctx,flags,buf,len) \
|
957
|
-
((void)
|
958
|
-
(void) duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_NOSOURCE))
|
996
|
+
((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
|
959
997
|
|
960
998
|
#define duk_compile_lstring_filename(ctx,flags,buf,len) \
|
961
|
-
((void) duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_NOSOURCE))
|
999
|
+
((void) duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))
|
962
1000
|
|
963
1001
|
#define duk_pcompile_lstring(ctx,flags,buf,len) \
|
964
|
-
((
|
965
|
-
duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
|
1002
|
+
(duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
|
966
1003
|
|
967
1004
|
#define duk_pcompile_lstring_filename(ctx,flags,buf,len) \
|
968
|
-
(duk_compile_raw((ctx), buf, len, (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
|
1005
|
+
(duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
|
969
1006
|
|
970
1007
|
/* file */
|
971
1008
|
#define duk_eval_file(ctx,path) \
|
972
1009
|
((void) duk_push_string_file_raw((ctx), (path), 0), \
|
973
1010
|
(void) duk_push_string((ctx), (path)), \
|
974
|
-
(void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL))
|
1011
|
+
(void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL))
|
975
1012
|
|
976
1013
|
#define duk_eval_file_noresult(ctx,path) \
|
977
1014
|
((void) duk_push_string_file_raw((ctx), (path), 0), \
|
978
1015
|
(void) duk_push_string((ctx), (path)), \
|
979
|
-
(void) duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
|
1016
|
+
(void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
|
980
1017
|
|
981
1018
|
#define duk_peval_file(ctx,path) \
|
982
1019
|
((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
|
983
1020
|
(void) duk_push_string((ctx), (path)), \
|
984
|
-
duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
|
1021
|
+
duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
|
985
1022
|
|
986
1023
|
#define duk_peval_file_noresult(ctx,path) \
|
987
1024
|
((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
|
988
1025
|
(void) duk_push_string((ctx), (path)), \
|
989
|
-
duk_eval_raw((ctx), NULL, 0, DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
|
1026
|
+
duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))
|
990
1027
|
|
991
1028
|
#define duk_compile_file(ctx,flags,path) \
|
992
1029
|
((void) duk_push_string_file_raw((ctx), (path), 0), \
|
993
1030
|
(void) duk_push_string((ctx), (path)), \
|
994
|
-
(void) duk_compile_raw((ctx), NULL, 0, (flags)))
|
1031
|
+
(void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
|
995
1032
|
|
996
1033
|
#define duk_pcompile_file(ctx,flags,path) \
|
997
1034
|
((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
|
998
1035
|
(void) duk_push_string((ctx), (path)), \
|
999
|
-
duk_compile_raw((ctx), NULL, 0, (flags) | DUK_COMPILE_SAFE))
|
1036
|
+
duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
|
1000
1037
|
|
1001
1038
|
/*
|
1002
1039
|
* Bytecode load/dump
|
@@ -1039,16 +1076,23 @@ DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);
|
|
1039
1076
|
* Debugger (debug protocol)
|
1040
1077
|
*/
|
1041
1078
|
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
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);
|
1050
1092
|
DUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);
|
1051
1093
|
DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);
|
1094
|
+
DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues);
|
1095
|
+
DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
|
1052
1096
|
|
1053
1097
|
/*
|
1054
1098
|
* Date provider related constants
|
@@ -1128,6 +1172,17 @@ DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);
|
|
1128
1172
|
#define DUK_DATE_FLAG_SEP_T (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */
|
1129
1173
|
#define DUK_DATE_FLAG_VALUE_SHIFT 12 /* additional values begin at bit 12 */
|
1130
1174
|
|
1175
|
+
/*
|
1176
|
+
* ROM pointer compression
|
1177
|
+
*/
|
1178
|
+
|
1179
|
+
/* Support array for ROM pointer compression. Only declared when ROM
|
1180
|
+
* pointer compression is active.
|
1181
|
+
*/
|
1182
|
+
#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)
|
1183
|
+
DUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];
|
1184
|
+
#endif
|
1185
|
+
|
1131
1186
|
/*
|
1132
1187
|
* C++ name mangling
|
1133
1188
|
*/
|
@@ -1203,13 +1258,13 @@ DUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);
|
|
1203
1258
|
union duk_double_union {
|
1204
1259
|
double d;
|
1205
1260
|
float f[2];
|
1206
|
-
#
|
1261
|
+
#if defined(DUK_USE_64BIT_OPS)
|
1207
1262
|
duk_uint64_t ull[1];
|
1208
1263
|
#endif
|
1209
1264
|
duk_uint32_t ui[2];
|
1210
1265
|
duk_uint16_t us[4];
|
1211
1266
|
duk_uint8_t uc[8];
|
1212
|
-
#
|
1267
|
+
#if defined(DUK_USE_PACKED_TVAL)
|
1213
1268
|
void *vp[2]; /* used by packed duk_tval, assumes sizeof(void *) == 4 */
|
1214
1269
|
#endif
|
1215
1270
|
};
|
@@ -1348,7 +1403,7 @@ typedef union duk_double_union duk_double_union;
|
|
1348
1403
|
*
|
1349
1404
|
* When packed duk_tval is used, the NaN space is used to store pointers
|
1350
1405
|
* and other tagged values in addition to NaNs. Actual NaNs are normalized
|
1351
|
-
* to a specific
|
1406
|
+
* to a specific quiet NaN. The macros below are used by the implementation
|
1352
1407
|
* to check and normalize NaN values when they might be created. The macros
|
1353
1408
|
* are essentially NOPs when the non-packed duk_tval representation is used.
|
1354
1409
|
*
|
@@ -1356,7 +1411,8 @@ typedef union duk_double_union duk_double_union;
|
|
1356
1411
|
* the packed duk_tval and works correctly for all NaNs except those that
|
1357
1412
|
* begin with 0x7ff0. Since the 'normalized NaN' values used with packed
|
1358
1413
|
* duk_tval begin with 0x7ff8, the partial check is reliable when packed
|
1359
|
-
* duk_tval is used.
|
1414
|
+
* duk_tval is used. The 0x7ff8 prefix means the normalized NaN will be a
|
1415
|
+
* quiet NaN regardless of its remaining lower bits.
|
1360
1416
|
*
|
1361
1417
|
* The ME variant below is specifically for ARM byte order, which has the
|
1362
1418
|
* feature that while doubles have a mixed byte order (32107654), unsigned
|