Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duktape.h File Reference
#include "duk_config.h"

Go to the source code of this file.

Data Structures

struct  duk_memory_functions
 
struct  duk_function_list_entry
 
struct  duk_number_list_entry
 
union  duk_double_union
 

Macros

#define DUK_SINGLE_FILE
 
#define DUK_API_PUBLIC_H_INCLUDED
 
#define DUK_API_NORETURN(decl)   DUK_NORETURN(decl)
 
#define DUK_VERSION   10502L
 
#define DUK_GIT_COMMIT   "cad34ae155acb0846545ca6bf2d29f9463b22bbb"
 
#define DUK_GIT_DESCRIBE   "v1.5.2"
 
#define DUK_GIT_BRANCH   "HEAD"
 
#define DUK_DEBUG_PROTOCOL_VERSION   1
 
#define DUK_INVALID_INDEX   DUK_IDX_MIN
 
#define DUK_VARARGS   ((duk_int_t) (-1))
 
#define DUK_API_ENTRY_STACK   64
 
#define DUK_TYPE_MIN   0
 
#define DUK_TYPE_NONE   0 /* no value, e.g. invalid index */
 
#define DUK_TYPE_UNDEFINED   1 /* Ecmascript undefined */
 
#define DUK_TYPE_NULL   2 /* Ecmascript null */
 
#define DUK_TYPE_BOOLEAN   3 /* Ecmascript boolean: 0 or 1 */
 
#define DUK_TYPE_NUMBER   4 /* Ecmascript number: double */
 
#define DUK_TYPE_STRING   5 /* Ecmascript string: CESU-8 / extended UTF-8 encoded */
 
#define DUK_TYPE_OBJECT   6 /* Ecmascript object: includes objects, arrays, functions, threads */
 
#define DUK_TYPE_BUFFER   7 /* fixed or dynamic, garbage collected byte buffer */
 
#define DUK_TYPE_POINTER   8 /* raw void pointer */
 
#define DUK_TYPE_LIGHTFUNC   9 /* lightweight function pointer */
 
#define DUK_TYPE_MAX   9
 
#define DUK_TYPE_MASK_NONE   (1 << DUK_TYPE_NONE)
 
#define DUK_TYPE_MASK_UNDEFINED   (1 << DUK_TYPE_UNDEFINED)
 
#define DUK_TYPE_MASK_NULL   (1 << DUK_TYPE_NULL)
 
#define DUK_TYPE_MASK_BOOLEAN   (1 << DUK_TYPE_BOOLEAN)
 
#define DUK_TYPE_MASK_NUMBER   (1 << DUK_TYPE_NUMBER)
 
#define DUK_TYPE_MASK_STRING   (1 << DUK_TYPE_STRING)
 
#define DUK_TYPE_MASK_OBJECT   (1 << DUK_TYPE_OBJECT)
 
#define DUK_TYPE_MASK_BUFFER   (1 << DUK_TYPE_BUFFER)
 
#define DUK_TYPE_MASK_POINTER   (1 << DUK_TYPE_POINTER)
 
#define DUK_TYPE_MASK_LIGHTFUNC   (1 << DUK_TYPE_LIGHTFUNC)
 
#define DUK_TYPE_MASK_THROW   (1 << 10) /* internal flag value: throw if mask doesn't match */
 
#define DUK_HINT_NONE
 
#define DUK_HINT_STRING   1 /* prefer string */
 
#define DUK_HINT_NUMBER   2 /* prefer number */
 
#define DUK_ENUM_INCLUDE_NONENUMERABLE   (1 << 0) /* enumerate non-numerable properties in addition to enumerable */
 
#define DUK_ENUM_INCLUDE_INTERNAL   (1 << 1) /* enumerate internal properties (regardless of enumerability) */
 
#define DUK_ENUM_OWN_PROPERTIES_ONLY   (1 << 2) /* don't walk prototype chain, only check own properties */
 
#define DUK_ENUM_ARRAY_INDICES_ONLY   (1 << 3) /* only enumerate array indices */
 
#define DUK_ENUM_SORT_ARRAY_INDICES   (1 << 4) /* sort array indices, use with DUK_ENUM_ARRAY_INDICES_ONLY */
 
#define DUK_ENUM_NO_PROXY_BEHAVIOR   (1 << 5) /* enumerate a proxy object itself without invoking proxy behavior */
 
#define DUK_COMPILE_EVAL   (1 << 3) /* compile eval code (instead of global code) */
 
#define DUK_COMPILE_FUNCTION   (1 << 4) /* compile function code (instead of global code) */
 
#define DUK_COMPILE_STRICT   (1 << 5) /* use strict (outer) context for global, eval, or function code */
 
#define DUK_COMPILE_SAFE   (1 << 6) /* (internal) catch compilation errors */
 
#define DUK_COMPILE_NORESULT   (1 << 7) /* (internal) omit eval result */
 
#define DUK_COMPILE_NOSOURCE   (1 << 8) /* (internal) no source string on stack */
 
#define DUK_COMPILE_STRLEN   (1 << 9) /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */
 
#define DUK_COMPILE_NOFILENAME   (1 << 10) /* (internal) no filename on stack */
 
#define DUK_DEFPROP_WRITABLE   (1 << 0) /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */
 
#define DUK_DEFPROP_ENUMERABLE   (1 << 1) /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */
 
#define DUK_DEFPROP_CONFIGURABLE   (1 << 2) /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */
 
#define DUK_DEFPROP_HAVE_WRITABLE   (1 << 3) /* set/clear writable */
 
#define DUK_DEFPROP_HAVE_ENUMERABLE   (1 << 4) /* set/clear enumerable */
 
#define DUK_DEFPROP_HAVE_CONFIGURABLE   (1 << 5) /* set/clear configurable */
 
#define DUK_DEFPROP_HAVE_VALUE   (1 << 6) /* set value (given on value stack) */
 
#define DUK_DEFPROP_HAVE_GETTER   (1 << 7) /* set getter (given on value stack) */
 
#define DUK_DEFPROP_HAVE_SETTER   (1 << 8) /* set setter (given on value stack) */
 
#define DUK_DEFPROP_FORCE   (1 << 9) /* force change if possible, may still fail for e.g. virtual properties */
 
#define DUK_DEFPROP_SET_WRITABLE   (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)
 
#define DUK_DEFPROP_CLEAR_WRITABLE   DUK_DEFPROP_HAVE_WRITABLE
 
#define DUK_DEFPROP_SET_ENUMERABLE   (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)
 
#define DUK_DEFPROP_CLEAR_ENUMERABLE   DUK_DEFPROP_HAVE_ENUMERABLE
 
#define DUK_DEFPROP_SET_CONFIGURABLE   (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)
 
#define DUK_DEFPROP_CLEAR_CONFIGURABLE   DUK_DEFPROP_HAVE_CONFIGURABLE
 
#define DUK_THREAD_NEW_GLOBAL_ENV   (1 << 0) /* create a new global environment */
 
#define DUK_STRING_PUSH_SAFE   (1 << 0) /* no error if file does not exist */
 
#define DUK_ERR_NONE   0 /* no error (e.g. from duk_get_error_code()) */
 
#define DUK_ERR_UNIMPLEMENTED_ERROR   50 /* UnimplementedError */ /* XXX: replace with TypeError? */
 
#define DUK_ERR_UNSUPPORTED_ERROR   51 /* UnsupportedError */ /* XXX: replace with TypeError? */
 
#define DUK_ERR_INTERNAL_ERROR   52 /* InternalError */ /* XXX: replace with plain Error? */
 
#define DUK_ERR_ALLOC_ERROR   53 /* AllocError */ /* XXX: replace with RangeError? */
 
#define DUK_ERR_ASSERTION_ERROR   54 /* AssertionError */ /* XXX: to be removed? */
 
#define DUK_ERR_API_ERROR   55 /* APIError */ /* XXX: replace with TypeError? */
 
#define DUK_ERR_UNCAUGHT_ERROR   56 /* UncaughtError */ /* XXX: to be removed? */
 
#define DUK_ERR_ERROR   100 /* Error */
 
#define DUK_ERR_EVAL_ERROR   101 /* EvalError */
 
#define DUK_ERR_RANGE_ERROR   102 /* RangeError */
 
#define DUK_ERR_REFERENCE_ERROR   103 /* ReferenceError */
 
#define DUK_ERR_SYNTAX_ERROR   104 /* SyntaxError */
 
#define DUK_ERR_TYPE_ERROR   105 /* TypeError */
 
#define DUK_ERR_URI_ERROR   106 /* URIError */
 
#define DUK_RET_UNIMPLEMENTED_ERROR   (-DUK_ERR_UNIMPLEMENTED_ERROR)
 
#define DUK_RET_UNSUPPORTED_ERROR   (-DUK_ERR_UNSUPPORTED_ERROR)
 
#define DUK_RET_INTERNAL_ERROR   (-DUK_ERR_INTERNAL_ERROR)
 
#define DUK_RET_ALLOC_ERROR   (-DUK_ERR_ALLOC_ERROR)
 
#define DUK_RET_ASSERTION_ERROR   (-DUK_ERR_ASSERTION_ERROR)
 
#define DUK_RET_API_ERROR   (-DUK_ERR_API_ERROR)
 
#define DUK_RET_UNCAUGHT_ERROR   (-DUK_ERR_UNCAUGHT_ERROR)
 
#define DUK_RET_ERROR   (-DUK_ERR_ERROR)
 
#define DUK_RET_EVAL_ERROR   (-DUK_ERR_EVAL_ERROR)
 
#define DUK_RET_RANGE_ERROR   (-DUK_ERR_RANGE_ERROR)
 
#define DUK_RET_REFERENCE_ERROR   (-DUK_ERR_REFERENCE_ERROR)
 
#define DUK_RET_SYNTAX_ERROR   (-DUK_ERR_SYNTAX_ERROR)
 
#define DUK_RET_TYPE_ERROR   (-DUK_ERR_TYPE_ERROR)
 
#define DUK_RET_URI_ERROR   (-DUK_ERR_URI_ERROR)
 
#define DUK_EXEC_SUCCESS   0
 
#define DUK_EXEC_ERROR   1
 
#define DUK_LOG_TRACE   0
 
#define DUK_LOG_DEBUG   1
 
#define DUK_LOG_INFO   2
 
#define DUK_LOG_WARN   3
 
#define DUK_LOG_ERROR   4
 
#define DUK_LOG_FATAL   5
 
#define duk_create_heap_default()    duk_create_heap(NULL, NULL, NULL, NULL, NULL)
 
#define duk_error
 
#define duk_error_va(ctx, err_code, fmt, ap)    duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
 
#define duk_xmove_top(to_ctx, from_ctx, count)    duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)
 
#define duk_xcopy_top(to_ctx, from_ctx, count)    duk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)
 
#define duk_push_string_file(ctx, path)    duk_push_string_file_raw((ctx), (path), 0)
 
#define duk_push_thread(ctx)    duk_push_thread_raw((ctx), 0 /*flags*/)
 
#define duk_push_thread_new_globalenv(ctx)    duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)
 
#define duk_push_error_object
 
#define duk_push_error_object_va(ctx, err_code, fmt, ap)    duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))
 
#define DUK_BUF_FLAG_DYNAMIC   (1 << 0) /* internal flag: dynamic buffer */
 
#define DUK_BUF_FLAG_EXTERNAL   (1 << 1) /* internal flag: external buffer */
 
#define DUK_BUF_FLAG_NOZERO   (1 << 2) /* internal flag: don't zero allocated buffer */
 
#define duk_push_buffer(ctx, size, dynamic)    duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)
 
#define duk_push_fixed_buffer(ctx, size)    duk_push_buffer_raw((ctx), (size), 0 /*flags*/)
 
#define duk_push_dynamic_buffer(ctx, size)    duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)
 
#define duk_push_external_buffer(ctx)    ((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))
 
#define DUK_BUFOBJ_CREATE_ARRBUF   (1 << 4) /* internal flag: create backing ArrayBuffer; keep in one byte */
 
#define DUK_BUFOBJ_DUKTAPE_BUFFER   0
 
#define DUK_BUFOBJ_NODEJS_BUFFER   1
 
#define DUK_BUFOBJ_ARRAYBUFFER   2
 
#define DUK_BUFOBJ_DATAVIEW   (3 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_INT8ARRAY   (4 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_UINT8ARRAY   (5 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_UINT8CLAMPEDARRAY   (6 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_INT16ARRAY   (7 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_UINT16ARRAY   (8 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_INT32ARRAY   (9 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_UINT32ARRAY   (10 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_FLOAT32ARRAY   (11 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define DUK_BUFOBJ_FLOAT64ARRAY   (12 | DUK_BUFOBJ_CREATE_ARRBUF)
 
#define duk_is_callable(ctx, index)    duk_is_function((ctx), (index))
 
#define duk_is_primitive(ctx, index)
 
#define duk_is_object_coercible(ctx, index)
 
#define duk_is_error(ctx, index)    (duk_get_error_code((ctx), (index)) != 0)
 
#define duk_is_eval_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_EVAL_ERROR)
 
#define duk_is_range_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_RANGE_ERROR)
 
#define duk_is_reference_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_REFERENCE_ERROR)
 
#define duk_is_syntax_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_SYNTAX_ERROR)
 
#define duk_is_type_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_TYPE_ERROR)
 
#define duk_is_uri_error(ctx, index)    (duk_get_error_code((ctx), (index)) == DUK_ERR_URI_ERROR)
 
#define duk_require_type_mask(ctx, index, mask)    ((void) duk_check_type_mask((ctx), (index), (mask) | DUK_TYPE_MASK_THROW))
 
#define duk_require_callable(ctx, index)    duk_require_function((ctx), (index))
 
#define duk_require_object_coercible(ctx, index)
 
#define DUK_BUF_MODE_FIXED   0 /* internal: request fixed buffer result */
 
#define DUK_BUF_MODE_DYNAMIC   1 /* internal: request dynamic buffer result */
 
#define DUK_BUF_MODE_DONTCARE   2 /* internal: don't care about fixed/dynamic nature */
 
#define duk_to_buffer(ctx, index, out_size)    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)
 
#define duk_to_fixed_buffer(ctx, index, out_size)    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)
 
#define duk_to_dynamic_buffer(ctx, index, out_size)    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DYNAMIC)
 
#define duk_safe_to_string(ctx, index)    duk_safe_to_lstring((ctx), (index), NULL)
 
#define duk_eval(ctx)    ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))
 
#define duk_eval_noresult(ctx)    ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
 
#define duk_peval(ctx)    (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
 
#define duk_peval_noresult(ctx)    (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
 
#define duk_compile(ctx, flags)    ((void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
 
#define duk_pcompile(ctx, flags)    (duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
 
#define duk_eval_string(ctx, src)    ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
 
#define duk_eval_string_noresult(ctx, src)    ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
 
#define duk_peval_string(ctx, src)    (duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
 
#define duk_peval_string_noresult(ctx, src)    (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))
 
#define duk_compile_string(ctx, flags, src)    ((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
 
#define duk_compile_string_filename(ctx, flags, src)    ((void) duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
 
#define duk_pcompile_string(ctx, flags, src)    (duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
 
#define duk_pcompile_string_filename(ctx, flags, src)    (duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
 
#define duk_eval_lstring(ctx, buf, len)    ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
 
#define duk_eval_lstring_noresult(ctx, buf, len)    ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
 
#define duk_peval_lstring(ctx, buf, len)    (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))
 
#define duk_peval_lstring_noresult(ctx, buf, len)    (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))
 
#define duk_compile_lstring(ctx, flags, buf, len)    ((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
 
#define duk_compile_lstring_filename(ctx, flags, buf, len)    ((void) duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))
 
#define duk_pcompile_lstring(ctx, flags, buf, len)    (duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
 
#define duk_pcompile_lstring_filename(ctx, flags, buf, len)    (duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))
 
#define duk_eval_file(ctx, path)
 
#define duk_eval_file_noresult(ctx, path)
 
#define duk_peval_file(ctx, path)
 
#define duk_peval_file_noresult(ctx, path)
 
#define duk_compile_file(ctx, flags, path)
 
#define duk_pcompile_file(ctx, flags, path)
 
#define duk_dump_context_filehandle(ctx, fh)
 
#define duk_dump_context_stdout(ctx)    duk_dump_context_filehandle((ctx), DUK_STDOUT)
 
#define duk_dump_context_stderr(ctx)    duk_dump_context_filehandle((ctx), DUK_STDERR)
 
#define duk_debugger_attach(ctx, read_cb, write_cb, peek_cb, read_flush_cb, write_flush_cb, detached_cb, udata)
 
#define DUK_DATE_MSEC_SECOND   1000L
 
#define DUK_DATE_MSEC_MINUTE   (60L * 1000L)
 
#define DUK_DATE_MSEC_HOUR   (60L * 60L * 1000L)
 
#define DUK_DATE_MSEC_DAY   (24L * 60L * 60L * 1000L)
 
#define DUK_DATE_MSEC_100M_DAYS   (8.64e15)
 
#define DUK_DATE_MSEC_100M_DAYS_LEEWAY   (8.64e15 + 24 * 3600e3)
 
#define DUK_DATE_MIN_ECMA_YEAR   (-271821L)
 
#define DUK_DATE_MAX_ECMA_YEAR   275760L
 
#define DUK_DATE_IDX_YEAR   0 /* year */
 
#define DUK_DATE_IDX_MONTH   1 /* month: 0 to 11 */
 
#define DUK_DATE_IDX_DAY   2 /* day within month: 0 to 30 */
 
#define DUK_DATE_IDX_HOUR   3
 
#define DUK_DATE_IDX_MINUTE   4
 
#define DUK_DATE_IDX_SECOND   5
 
#define DUK_DATE_IDX_MILLISECOND   6
 
#define DUK_DATE_IDX_WEEKDAY   7 /* weekday: 0 to 6, 0=sunday, 1=monday, etc */
 
#define DUK_DATE_IDX_NUM_PARTS   8
 
#define DUK_DATE_FLAG_NAN_TO_ZERO   (1 << 0) /* timeval breakdown: internal time value NaN -> zero */
 
#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR   (1 << 1) /* timeval breakdown: internal time value NaN -> RangeError (toISOString) */
 
#define DUK_DATE_FLAG_ONEBASED   (1 << 2) /* timeval breakdown: convert month and day-of-month parts to one-based (default is zero-based) */
 
#define DUK_DATE_FLAG_EQUIVYEAR   (1 << 3) /* timeval breakdown: replace year with equivalent year in the [1971,2037] range for DST calculations */
 
#define DUK_DATE_FLAG_LOCALTIME   (1 << 4) /* convert time value to local time */
 
#define DUK_DATE_FLAG_SUB1900   (1 << 5) /* getter: subtract 1900 from year when getting year part */
 
#define DUK_DATE_FLAG_TOSTRING_DATE   (1 << 6) /* include date part in string conversion result */
 
#define DUK_DATE_FLAG_TOSTRING_TIME   (1 << 7) /* include time part in string conversion result */
 
#define DUK_DATE_FLAG_TOSTRING_LOCALE   (1 << 8) /* use locale specific formatting if available */
 
#define DUK_DATE_FLAG_TIMESETTER   (1 << 9) /* setter: call is a time setter (affects hour, min, sec, ms); otherwise date setter (affects year, month, day-in-month) */
 
#define DUK_DATE_FLAG_YEAR_FIXUP   (1 << 10) /* setter: perform 2-digit year fixup (00...99 -> 1900...1999) */
 
#define DUK_DATE_FLAG_SEP_T   (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */
 
#define DUK_DATE_FLAG_VALUE_SHIFT   12 /* additional values begin at bit 12 */
 
#define DUK_DBLUNION_H_INCLUDED
 
#define DUK_DBLUNION_SET_DOUBLE(u, v)
 
#define DUK_DBLUNION_SET_HIGH32(u, v)
 
#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u, v)
 
#define DUK_DBLUNION_SET_LOW32(u, v)
 
#define DUK_DBLUNION_GET_DOUBLE(u)   ((u)->d)
 
#define DUK_DBLUNION_GET_HIGH32(u)   ((u)->ui[DUK_DBL_IDX_UI0])
 
#define DUK_DBLUNION_GET_LOW32(u)   ((u)->ui[DUK_DBL_IDX_UI1])
 
#define DUK__DBLUNION_SET_NAN_FULL(u)
 
#define DUK__DBLUNION_SET_NAN_NOTFULL(u)
 
#define DUK__DBLUNION_IS_NAN_FULL(u)
 
#define DUK__DBLUNION_IS_NAN_NOTFULL(u)
 
#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u)
 
#define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL(u)
 
#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL(u)
 
#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL(u)
 
#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)   /* nop: no need to normalize */
 
#define DUK_DBLUNION_IS_NAN(u)   (DUK_ISNAN((u)->d))
 
#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)   (DUK_ISNAN((u)->d))
 
#define DUK_DBLUNION_IS_NORMALIZED(u)   1 /* all doubles are considered normalized */
 
#define DUK_DBLUNION_SET_NAN(u)
 
#define DUK_DBLUNION_BSWAP64(u)
 
#define DUK_DBLUNION_DOUBLE_NTOH(u)   DUK_DBLUNION_DOUBLE_HTON((u))
 

Typedefs

typedef struct duk_memory_functions duk_memory_functions
 
typedef struct duk_function_list_entry duk_function_list_entry
 
typedef struct duk_number_list_entry duk_number_list_entry
 
typedef duk_ret_t(* duk_c_function) (duk_context *ctx)
 
typedef void *(* duk_alloc_function) (void *udata, duk_size_t size)
 
typedef void *(* duk_realloc_function) (void *udata, void *ptr, duk_size_t size)
 
typedef void(* duk_free_function) (void *udata, void *ptr)
 
typedef void(* duk_fatal_function) (duk_context *ctx, duk_errcode_t code, const char *msg)
 
typedef void(* duk_decode_char_function) (void *udata, duk_codepoint_t codepoint)
 
typedef duk_codepoint_t(* duk_map_char_function) (void *udata, duk_codepoint_t codepoint)
 
typedef duk_ret_t(* duk_safe_call_function) (duk_context *ctx)
 
typedef duk_size_t(* duk_debug_read_function) (void *udata, char *buffer, duk_size_t length)
 
typedef duk_size_t(* duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length)
 
typedef duk_size_t(* duk_debug_peek_function) (void *udata)
 
typedef void(* duk_debug_read_flush_function) (void *udata)
 
typedef void(* duk_debug_write_flush_function) (void *udata)
 
typedef duk_idx_t(* duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues)
 
typedef void(* duk_debug_detached_function) (void *udata)
 
typedef union duk_double_union duk_double_union
 

Functions

DUK_EXTERNAL_DECL duk_contextduk_create_heap (duk_alloc_function alloc_func, duk_realloc_function realloc_func, duk_free_function free_func, void *heap_udata, duk_fatal_function fatal_handler)
 
DUK_EXTERNAL_DECL void duk_destroy_heap (duk_context *ctx)
 
DUK_EXTERNAL_DECL void * duk_alloc_raw (duk_context *ctx, duk_size_t size)
 
DUK_EXTERNAL_DECL void duk_free_raw (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL_DECL void * duk_realloc_raw (duk_context *ctx, void *ptr, duk_size_t size)
 
DUK_EXTERNAL_DECL void * duk_alloc (duk_context *ctx, duk_size_t size)
 
DUK_EXTERNAL_DECL void duk_free (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL_DECL void * duk_realloc (duk_context *ctx, void *ptr, duk_size_t size)
 
DUK_EXTERNAL_DECL void duk_get_memory_functions (duk_context *ctx, duk_memory_functions *out_funcs)
 
DUK_EXTERNAL_DECL void duk_gc (duk_context *ctx, duk_uint_t flags)
 
 DUK_API_NORETURN (DUK_EXTERNAL_DECL void duk_throw(duk_context *ctx))
 
 DUK_API_NORETURN (DUK_EXTERNAL_DECL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg))
 
 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,...))
 
 DUK_API_NORETURN (DUK_EXTERNAL_DECL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt,...))
 
 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))
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_require_valid_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_idx_t duk_get_top (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_set_top (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_bool_t duk_check_stack (duk_context *ctx, duk_idx_t extra)
 
DUK_EXTERNAL_DECL void duk_require_stack (duk_context *ctx, duk_idx_t extra)
 
DUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top (duk_context *ctx, duk_idx_t top)
 
DUK_EXTERNAL_DECL void duk_require_stack_top (duk_context *ctx, duk_idx_t top)
 
DUK_EXTERNAL_DECL void duk_swap (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL_DECL void duk_swap_top (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_dup (duk_context *ctx, duk_idx_t from_index)
 
DUK_EXTERNAL_DECL void duk_dup_top (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_insert (duk_context *ctx, duk_idx_t to_index)
 
DUK_EXTERNAL_DECL void duk_replace (duk_context *ctx, duk_idx_t to_index)
 
DUK_EXTERNAL_DECL void duk_copy (duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index)
 
DUK_EXTERNAL_DECL void duk_remove (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_xcopymove_raw (duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy)
 
DUK_EXTERNAL_DECL void duk_push_undefined (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_null (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_boolean (duk_context *ctx, duk_bool_t val)
 
DUK_EXTERNAL_DECL void duk_push_true (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_false (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_number (duk_context *ctx, duk_double_t val)
 
DUK_EXTERNAL_DECL void duk_push_nan (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_int (duk_context *ctx, duk_int_t val)
 
DUK_EXTERNAL_DECL void duk_push_uint (duk_context *ctx, duk_uint_t val)
 
DUK_EXTERNAL_DECL const char * duk_push_string (duk_context *ctx, const char *str)
 
DUK_EXTERNAL_DECL const char * duk_push_lstring (duk_context *ctx, const char *str, duk_size_t len)
 
DUK_EXTERNAL_DECL void duk_push_pointer (duk_context *ctx, void *p)
 
DUK_EXTERNAL_DECL const char * duk_push_sprintf (duk_context *ctx, const char *fmt,...)
 
DUK_EXTERNAL_DECL const char * duk_push_vsprintf (duk_context *ctx, const char *fmt, va_list ap)
 
DUK_EXTERNAL_DECL const char * duk_push_string_file_raw (duk_context *ctx, const char *path, duk_uint_t flags)
 
DUK_EXTERNAL_DECL void duk_push_this (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_current_function (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_current_thread (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_global_object (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_heap_stash (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_global_stash (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_push_thread_stash (duk_context *ctx, duk_context *target_ctx)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_object (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_array (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function (duk_context *ctx, duk_c_function func, duk_idx_t nargs)
 
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)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw (duk_context *ctx, duk_uint_t flags)
 
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,...)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash (duk_context *ctx, duk_errcode_t err_code, const char *fmt,...)
 
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)
 
DUK_EXTERNAL_DECL void * duk_push_buffer_raw (duk_context *ctx, duk_size_t size, duk_small_uint_t flags)
 
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)
 
DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL_DECL void duk_pop (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_pop_n (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL_DECL void duk_pop_2 (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_pop_3 (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_int_t duk_get_type (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_check_type (duk_context *ctx, duk_idx_t index, duk_int_t type)
 
DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask (duk_context *ctx, duk_idx_t index, duk_uint_t mask)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_nan (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_object (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_array (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_thread (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_double_t duk_get_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_int_t duk_get_int (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_uint_t duk_get_uint (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_get_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_get_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL_DECL void * duk_get_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL_DECL void * duk_get_buffer_data (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL_DECL void * duk_get_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_c_function duk_get_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_contextduk_get_context (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void * duk_get_heapptr (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_size_t duk_get_length (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_require_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_require_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_double_t duk_require_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_int_t duk_require_int (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_uint_t duk_require_uint (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_require_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_require_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL_DECL void * duk_require_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL_DECL void * duk_require_buffer_data (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL_DECL void * duk_require_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_c_function duk_require_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_contextduk_require_context (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_require_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void * duk_require_heapptr (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_to_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_to_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_double_t duk_to_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_int_t duk_to_int (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_uint_t duk_to_uint (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_int32_t duk_to_int32 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_to_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_to_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL_DECL void * duk_to_buffer_raw (duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t flags)
 
DUK_EXTERNAL_DECL void * duk_to_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_to_object (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_to_defaultvalue (duk_context *ctx, duk_idx_t index, duk_int_t hint)
 
DUK_EXTERNAL_DECL void duk_to_primitive (duk_context *ctx, duk_idx_t index, duk_int_t hint)
 
DUK_EXTERNAL_DECL const char * duk_safe_to_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL_DECL const char * duk_base64_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_base64_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_hex_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_hex_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL const char * duk_json_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_json_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void * duk_resize_buffer (duk_context *ctx, duk_idx_t index, duk_size_t new_size)
 
DUK_EXTERNAL_DECL void * duk_steal_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL_DECL void duk_config_buffer (duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len)
 
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL_DECL void duk_def_prop (duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags)
 
DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string (duk_context *ctx, const char *key)
 
DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string (duk_context *ctx, const char *key)
 
DUK_EXTERNAL_DECL void duk_get_prototype (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_set_prototype (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_get_finalizer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_set_finalizer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_set_global_object (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_int_t duk_get_magic (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL void duk_set_magic (duk_context *ctx, duk_idx_t index, duk_int_t magic)
 
DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_put_function_list (duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs)
 
DUK_EXTERNAL_DECL void duk_put_number_list (duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers)
 
DUK_EXTERNAL_DECL void duk_get_var (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_put_var (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_bool_t duk_del_var (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_bool_t duk_has_var (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_compact (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL_DECL void duk_enum (duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags)
 
DUK_EXTERNAL_DECL duk_bool_t duk_next (duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value)
 
DUK_EXTERNAL_DECL void duk_concat (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL_DECL void duk_join (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL_DECL void duk_decode_string (duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata)
 
DUK_EXTERNAL_DECL void duk_map_string (duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata)
 
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)
 
DUK_EXTERNAL_DECL void duk_trim (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at (duk_context *ctx, duk_idx_t index, duk_size_t char_offset)
 
DUK_EXTERNAL_DECL duk_bool_t duk_equals (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL_DECL duk_bool_t duk_instanceof (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL_DECL void duk_call (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL void duk_call_method (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL void duk_call_prop (duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL duk_int_t duk_pcall (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL duk_int_t duk_pcall_method (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop (duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL void duk_new (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL_DECL duk_int_t duk_pnew (duk_context *ctx, duk_idx_t nargs)
 
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)
 
DUK_EXTERNAL_DECL duk_int_t duk_eval_raw (duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
 
DUK_EXTERNAL_DECL duk_int_t duk_compile_raw (duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
 
DUK_EXTERNAL_DECL void duk_dump_function (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_load_function (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_log (duk_context *ctx, duk_int_t level, const char *fmt,...)
 
DUK_EXTERNAL_DECL void duk_log_va (duk_context *ctx, duk_int_t level, const char *fmt, va_list ap)
 
DUK_EXTERNAL_DECL void duk_push_context_dump (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_debugger_attach_custom (duk_context *ctx, duk_debug_read_function read_cb, duk_debug_write_function write_cb, duk_debug_peek_function peek_cb, duk_debug_read_flush_function read_flush_cb, duk_debug_write_flush_function write_flush_cb, duk_debug_request_function request_cb, duk_debug_detached_function detached_cb, void *udata)
 
DUK_EXTERNAL_DECL void duk_debugger_detach (duk_context *ctx)
 
DUK_EXTERNAL_DECL void duk_debugger_cooperate (duk_context *ctx)
 
DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify (duk_context *ctx, duk_idx_t nvalues)
 
DUK_EXTERNAL_DECL void duk_debugger_pause (duk_context *ctx)
 

Variables

DUK_EXTERNAL_DECL const char * duk_api_global_filename
 
DUK_EXTERNAL_DECL duk_int_t duk_api_global_line
 

Macro Definition Documentation

◆ DUK__DBLUNION_IS_NAN_FULL

#define DUK__DBLUNION_IS_NAN_FULL ( u)
Value:
/* E == 0x7ff, F != 0 => NaN */ \
((((u)->ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL) && \
(((u)->ui[DUK_DBL_IDX_UI0] & 0x000fffffUL) != 0 || \
(u)->ui[DUK_DBL_IDX_UI1] != 0))

Definition at line 1444 of file duktape-1.5.2/src-noline/duktape.h.

1444#endif
1445#else /* DUK_USE_64BIT_OPS */
1446#define DUK__DBLUNION_IS_NAN_FULL(u) \
1447 /* E == 0x7ff, F != 0 => NaN */ \
1448 ((((u)->ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL) && \

◆ DUK__DBLUNION_IS_NAN_NOTFULL

#define DUK__DBLUNION_IS_NAN_NOTFULL ( u)
Value:
/* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \
((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \
(((u)->us[DUK_DBL_IDX_US0] & 0x000fUL) != 0x0000UL))

Definition at line 1451 of file duktape-1.5.2/src-noline/duktape.h.

1451#endif /* DUK_USE_64BIT_OPS */
1452
1453#define DUK__DBLUNION_IS_NAN_NOTFULL(u) \
1454 /* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \

◆ DUK__DBLUNION_IS_NORMALIZED_NAN_FULL

#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL ( u)
Value:
(((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff80000UL) && \
((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))

Definition at line 1465 of file duktape-1.5.2/src-noline/duktape.h.

1465#endif
1466#else /* DUK_USE_64BIT_OPS */
1467#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \

◆ DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL

#define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL ( u)
Value:
/* E == 0x7ff, F == 8 => normalized NaN */ \
((u)->us[DUK_DBL_IDX_US0] == 0x7ff8UL)

Definition at line 1470 of file duktape-1.5.2/src-noline/duktape.h.

1470#endif /* DUK_USE_64BIT_OPS */
1471
1472#define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL(u) \

◆ DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL

#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL ( u)
Value:
do { \
DUK__DBLUNION_SET_NAN_FULL((u)); \
} \
} while (0)
#define DUK__DBLUNION_IS_NAN_FULL(u)

Definition at line 1474 of file duktape-1.5.2/src-noline/duktape.h.

1474 ((u)->us[DUK_DBL_IDX_US0] == 0x7ff8UL)
1475
1476#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL(u) do { \
1477 if (DUK__DBLUNION_IS_NAN_FULL((u))) { \
1478 DUK__DBLUNION_SET_NAN_FULL((u)); \

◆ DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL

#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL ( u)
Value:
do { \
DUK__DBLUNION_SET_NAN_NOTFULL((u)); \
} \
} while (0)
#define DUK__DBLUNION_IS_NAN_NOTFULL(u)

Definition at line 1480 of file duktape-1.5.2/src-noline/duktape.h.

1480 } while (0)
1481
1482#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL(u) do { \
1483 if (DUK__DBLUNION_IS_NAN_NOTFULL((u))) { \
1484 DUK__DBLUNION_SET_NAN_NOTFULL((u)); \

◆ DUK__DBLUNION_SET_NAN_FULL

#define DUK__DBLUNION_SET_NAN_FULL ( u)
Value:
do { \
(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) 0x7ff80000UL; \
(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0x00000000UL; \
} while (0)

Definition at line 1421 of file duktape-1.5.2/src-noline/duktape.h.

1421#endif
1422#else /* DUK_USE_64BIT_OPS */
1423#define DUK__DBLUNION_SET_NAN_FULL(u) do { \
1424 (u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) 0x7ff80000UL; \

◆ DUK__DBLUNION_SET_NAN_NOTFULL

#define DUK__DBLUNION_SET_NAN_NOTFULL ( u)
Value:
do { \
(u)->us[DUK_DBL_IDX_US0] = 0x7ff8UL; \
} while (0)

Definition at line 1427 of file duktape-1.5.2/src-noline/duktape.h.

1427#endif /* DUK_USE_64BIT_OPS */
1428
1429#define DUK__DBLUNION_SET_NAN_NOTFULL(u) do { \

◆ DUK_API_ENTRY_STACK

#define DUK_API_ENTRY_STACK   64

Definition at line 249 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_API_NORETURN

#define DUK_API_NORETURN ( decl )    DUK_NORETURN(decl)

Definition at line 156 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_API_PUBLIC_H_INCLUDED

#define DUK_API_PUBLIC_H_INCLUDED

Definition at line 137 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUF_FLAG_DYNAMIC

#define DUK_BUF_FLAG_DYNAMIC   (1 << 0) /* internal flag: dynamic buffer */

Definition at line 562 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_hbuffer_alloc().

◆ DUK_BUF_FLAG_EXTERNAL

#define DUK_BUF_FLAG_EXTERNAL   (1 << 1) /* internal flag: external buffer */

Definition at line 563 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_hbuffer_alloc().

◆ DUK_BUF_FLAG_NOZERO

#define DUK_BUF_FLAG_NOZERO   (1 << 2) /* internal flag: don't zero allocated buffer */

◆ DUK_BUF_MODE_DONTCARE

#define DUK_BUF_MODE_DONTCARE   2 /* internal: don't care about fixed/dynamic nature */

Definition at line 761 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_to_buffer_raw().

◆ DUK_BUF_MODE_DYNAMIC

#define DUK_BUF_MODE_DYNAMIC   1 /* internal: request dynamic buffer result */

Definition at line 760 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_to_buffer_raw().

◆ DUK_BUF_MODE_FIXED

#define DUK_BUF_MODE_FIXED   0 /* internal: request fixed buffer result */

Definition at line 759 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_to_buffer_raw().

◆ DUK_BUFOBJ_ARRAYBUFFER

#define DUK_BUFOBJ_ARRAYBUFFER   2

Definition at line 580 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_CREATE_ARRBUF

#define DUK_BUFOBJ_CREATE_ARRBUF   (1 << 4) /* internal flag: create backing ArrayBuffer; keep in one byte */

Definition at line 577 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_push_buffer_object().

◆ DUK_BUFOBJ_DATAVIEW

#define DUK_BUFOBJ_DATAVIEW   (3 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 581 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_DUKTAPE_BUFFER

#define DUK_BUFOBJ_DUKTAPE_BUFFER   0

Definition at line 578 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_FLOAT32ARRAY

#define DUK_BUFOBJ_FLOAT32ARRAY   (11 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 589 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_FLOAT64ARRAY

#define DUK_BUFOBJ_FLOAT64ARRAY   (12 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 590 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_INT16ARRAY

#define DUK_BUFOBJ_INT16ARRAY   (7 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 585 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_INT32ARRAY

#define DUK_BUFOBJ_INT32ARRAY   (9 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 587 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_INT8ARRAY

#define DUK_BUFOBJ_INT8ARRAY   (4 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 582 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_NODEJS_BUFFER

#define DUK_BUFOBJ_NODEJS_BUFFER   1

Definition at line 579 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_UINT16ARRAY

#define DUK_BUFOBJ_UINT16ARRAY   (8 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 586 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_UINT32ARRAY

#define DUK_BUFOBJ_UINT32ARRAY   (10 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 588 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_UINT8ARRAY

#define DUK_BUFOBJ_UINT8ARRAY   (5 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 583 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_BUFOBJ_UINT8CLAMPEDARRAY

#define DUK_BUFOBJ_UINT8CLAMPEDARRAY   (6 | DUK_BUFOBJ_CREATE_ARRBUF)

Definition at line 584 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_compile

#define duk_compile ( ctx,
flags )    ((void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))

Definition at line 936 of file duktape-1.5.2/src-noline/duktape.h.

937
DUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
#define DUK_COMPILE_NORESULT
#define DUK_COMPILE_NOFILENAME
#define NULL
Definition gmacros.h:924

Referenced by do_sandbox_test(), do_sandbox_test(), and wrapped_compile_execute().

◆ DUK_COMPILE_EVAL

#define DUK_COMPILE_EVAL   (1 << 3) /* compile eval code (instead of global code) */

◆ duk_compile_file

#define duk_compile_file ( ctx,
flags,
path )
Value:
((void) duk_push_string_file_raw((ctx), (path), 0), \
(void) duk_push_string((ctx), (path)), \
(void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
DUK_EXTERNAL_DECL const char * duk_push_string(duk_context *ctx, const char *str)
DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
DUK_EXTERNAL_DECL const char * duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags)

Definition at line 1013 of file duktape-1.5.2/src-noline/duktape.h.

1014
1015#define duk_compile_file(ctx,flags,path) \
1016 ((void) duk_push_string_file_raw((ctx), (path), 0), \
#define duk_compile_file(ctx, flags, path)

◆ DUK_COMPILE_FUNCTION

#define DUK_COMPILE_FUNCTION   (1 << 4) /* compile function code (instead of global code) */

Definition at line 297 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__do_compile().

◆ duk_compile_lstring

#define duk_compile_lstring ( ctx,
flags,
buf,
len )    ((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))

◆ duk_compile_lstring_filename

#define duk_compile_lstring_filename ( ctx,
flags,
buf,
len )    ((void) duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))

Definition at line 983 of file duktape-1.5.2/src-noline/duktape.h.

983 ((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
984

Referenced by wrapped_compile_execute(), and wrapped_compile_execute().

◆ DUK_COMPILE_NOFILENAME

#define DUK_COMPILE_NOFILENAME   (1 << 10) /* (internal) no filename on stack */

Definition at line 303 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__do_compile(), and duk_compile_raw().

◆ DUK_COMPILE_NORESULT

#define DUK_COMPILE_NORESULT   (1 << 7) /* (internal) omit eval result */

Definition at line 300 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_eval_raw().

◆ DUK_COMPILE_NOSOURCE

#define DUK_COMPILE_NOSOURCE   (1 << 8) /* (internal) no source string on stack */

Definition at line 301 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__do_compile(), and duk_compile_raw().

◆ DUK_COMPILE_SAFE

#define DUK_COMPILE_SAFE   (1 << 6) /* (internal) catch compilation errors */

Definition at line 299 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_compile_raw(), and duk_eval_raw().

◆ DUK_COMPILE_STRICT

#define DUK_COMPILE_STRICT   (1 << 5) /* use strict (outer) context for global, eval, or function code */

Definition at line 298 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__do_compile().

◆ duk_compile_string

#define duk_compile_string ( ctx,
flags,
src )    ((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))

◆ duk_compile_string_filename

#define duk_compile_string_filename ( ctx,
flags,
src )    ((void) duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))

Definition at line 958 of file duktape-1.5.2/src-noline/duktape.h.

958 ((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))
959

◆ DUK_COMPILE_STRLEN

#define DUK_COMPILE_STRLEN   (1 << 9) /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */

Definition at line 302 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_compile_raw().

◆ duk_create_heap_default

#define duk_create_heap_default ( )     duk_create_heap(NULL, NULL, NULL, NULL, NULL)

◆ DUK_DATE_FLAG_EQUIVYEAR

#define DUK_DATE_FLAG_EQUIVYEAR   (1 << 3) /* timeval breakdown: replace year with equivalent year in the [1971,2037] range for DST calculations */

◆ DUK_DATE_FLAG_LOCALTIME

#define DUK_DATE_FLAG_LOCALTIME   (1 << 4) /* convert time value to local time */

◆ DUK_DATE_FLAG_NAN_TO_RANGE_ERROR

#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR   (1 << 1) /* timeval breakdown: internal time value NaN -> RangeError (toISOString) */

◆ DUK_DATE_FLAG_NAN_TO_ZERO

#define DUK_DATE_FLAG_NAN_TO_ZERO   (1 << 0) /* timeval breakdown: internal time value NaN -> zero */

◆ DUK_DATE_FLAG_ONEBASED

#define DUK_DATE_FLAG_ONEBASED   (1 << 2) /* timeval breakdown: convert month and day-of-month parts to one-based (default is zero-based) */

◆ DUK_DATE_FLAG_SEP_T

#define DUK_DATE_FLAG_SEP_T   (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */

◆ DUK_DATE_FLAG_SUB1900

#define DUK_DATE_FLAG_SUB1900   (1 << 5) /* getter: subtract 1900 from year when getting year part */

Definition at line 1151 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__get_part_helper().

◆ DUK_DATE_FLAG_TIMESETTER

#define DUK_DATE_FLAG_TIMESETTER   (1 << 9) /* setter: call is a time setter (affects hour, min, sec, ms); otherwise date setter (affects year, month, day-in-month) */

Definition at line 1155 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__set_part_helper().

◆ DUK_DATE_FLAG_TOSTRING_DATE

#define DUK_DATE_FLAG_TOSTRING_DATE   (1 << 6) /* include date part in string conversion result */

◆ DUK_DATE_FLAG_TOSTRING_LOCALE

#define DUK_DATE_FLAG_TOSTRING_LOCALE   (1 << 8) /* use locale specific formatting if available */

Definition at line 1154 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__to_string_helper().

◆ DUK_DATE_FLAG_TOSTRING_TIME

#define DUK_DATE_FLAG_TOSTRING_TIME   (1 << 7) /* include time part in string conversion result */

◆ DUK_DATE_FLAG_VALUE_SHIFT

#define DUK_DATE_FLAG_VALUE_SHIFT   12 /* additional values begin at bit 12 */

◆ DUK_DATE_FLAG_YEAR_FIXUP

#define DUK_DATE_FLAG_YEAR_FIXUP   (1 << 10) /* setter: perform 2-digit year fixup (00...99 -> 1900...1999) */

Definition at line 1156 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__set_part_helper().

◆ DUK_DATE_IDX_DAY

◆ DUK_DATE_IDX_HOUR

#define DUK_DATE_IDX_HOUR   3

◆ DUK_DATE_IDX_MILLISECOND

◆ DUK_DATE_IDX_MINUTE

#define DUK_DATE_IDX_MINUTE   4

◆ DUK_DATE_IDX_MONTH

◆ DUK_DATE_IDX_NUM_PARTS

◆ DUK_DATE_IDX_SECOND

#define DUK_DATE_IDX_SECOND   5

◆ DUK_DATE_IDX_WEEKDAY

#define DUK_DATE_IDX_WEEKDAY   7 /* weekday: 0 to 6, 0=sunday, 1=monday, etc */

Definition at line 1127 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_bi_date_timeval_to_parts().

◆ DUK_DATE_IDX_YEAR

◆ DUK_DATE_MAX_ECMA_YEAR

#define DUK_DATE_MAX_ECMA_YEAR   275760L

◆ DUK_DATE_MIN_ECMA_YEAR

#define DUK_DATE_MIN_ECMA_YEAR   (-271821L)

◆ DUK_DATE_MSEC_100M_DAYS

#define DUK_DATE_MSEC_100M_DAYS   (8.64e15)

◆ DUK_DATE_MSEC_100M_DAYS_LEEWAY

#define DUK_DATE_MSEC_100M_DAYS_LEEWAY   (8.64e15 + 24 * 3600e3)

◆ DUK_DATE_MSEC_DAY

#define DUK_DATE_MSEC_DAY   (24L * 60L * 60L * 1000L)

◆ DUK_DATE_MSEC_HOUR

#define DUK_DATE_MSEC_HOUR   (60L * 60L * 1000L)

◆ DUK_DATE_MSEC_MINUTE

#define DUK_DATE_MSEC_MINUTE   (60L * 1000L)

◆ DUK_DATE_MSEC_SECOND

#define DUK_DATE_MSEC_SECOND   1000L

◆ DUK_DBLUNION_BSWAP64

#define DUK_DBLUNION_BSWAP64 ( u)
Value:
do { \
duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \
duk__bswaptmp1 = (u)->ui[0]; \
duk__bswaptmp2 = (u)->ui[1]; \
duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \
duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \
(u)->ui[0] = duk__bswaptmp2; \
(u)->ui[1] = duk__bswaptmp1; \
} while (0)

Definition at line 1521 of file duktape-1.5.2/src-noline/duktape.h.

1521
1522/* 64-bit byteswap, same operation independent of target endianness. */
1523#define DUK_DBLUNION_BSWAP64(u) do { \
1524 duk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \
1525 duk__bswaptmp1 = (u)->ui[0]; \
1526 duk__bswaptmp2 = (u)->ui[1]; \
1527 duk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \
1528 duk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \
1529 (u)->ui[0] = duk__bswaptmp2; \

Referenced by duk_bi_buffer_readfield(), and duk_bi_buffer_writefield().

◆ DUK_DBLUNION_DOUBLE_NTOH

#define DUK_DBLUNION_DOUBLE_NTOH ( u)    DUK_DBLUNION_DOUBLE_HTON((u))

Definition at line 1561 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DBLUNION_GET_DOUBLE

#define DUK_DBLUNION_GET_DOUBLE ( u)    ((u)->d)

Definition at line 1361 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__dragon4_ctx_to_double().

◆ DUK_DBLUNION_GET_HIGH32

#define DUK_DBLUNION_GET_HIGH32 ( u)    ((u)->ui[DUK_DBL_IDX_UI0])

◆ DUK_DBLUNION_GET_LOW32

#define DUK_DBLUNION_GET_LOW32 ( u)    ((u)->ui[DUK_DBL_IDX_UI1])

◆ DUK_DBLUNION_H_INCLUDED

#define DUK_DBLUNION_H_INCLUDED

Definition at line 1237 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DBLUNION_IS_NAN

#define DUK_DBLUNION_IS_NAN ( u)    (DUK_ISNAN((u)->d))

Definition at line 1509 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DBLUNION_IS_NORMALIZED

#define DUK_DBLUNION_IS_NORMALIZED ( u)    1 /* all doubles are considered normalized */

◆ DUK_DBLUNION_IS_NORMALIZED_NAN

#define DUK_DBLUNION_IS_NORMALIZED_NAN ( u)    (DUK_ISNAN((u)->d))

Definition at line 1510 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DBLUNION_NORMALIZE_NAN_CHECK

#define DUK_DBLUNION_NORMALIZE_NAN_CHECK ( u)    /* nop: no need to normalize */

◆ DUK_DBLUNION_SET_DOUBLE

#define DUK_DBLUNION_SET_DOUBLE ( u,
v )
Value:
do { \
(u)->d = (v); \
} while (0)

Definition at line 1332 of file duktape-1.5.2/src-noline/duktape.h.

1332 */
1333
1334#define DUK_DBLUNION_SET_DOUBLE(u,v) do { \

Referenced by duk__dragon4_double_to_ctx().

◆ DUK_DBLUNION_SET_HIGH32

#define DUK_DBLUNION_SET_HIGH32 ( u,
v )
Value:
do { \
(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \
} while (0)

Definition at line 1336 of file duktape-1.5.2/src-noline/duktape.h.

1336 } while (0)
1337
1338#define DUK_DBLUNION_SET_HIGH32(u,v) do { \

Referenced by duk__dragon4_ctx_to_double().

◆ DUK_DBLUNION_SET_HIGH32_ZERO_LOW32

#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32 ( u,
v )
Value:
do { \
(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \
(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0; \
} while (0)

Definition at line 1351 of file duktape-1.5.2/src-noline/duktape.h.

1351#endif
1352#else /* DUK_USE_64BIT_OPS */
1353#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v) do { \
1354 (u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \

◆ DUK_DBLUNION_SET_LOW32

#define DUK_DBLUNION_SET_LOW32 ( u,
v )
Value:
do { \
(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \
} while (0)

Definition at line 1357 of file duktape-1.5.2/src-noline/duktape.h.

1357#endif /* DUK_USE_64BIT_OPS */
1358
1359#define DUK_DBLUNION_SET_LOW32(u,v) do { \

Referenced by duk__dragon4_ctx_to_double().

◆ DUK_DBLUNION_SET_NAN

#define DUK_DBLUNION_SET_NAN ( u)
Value:
do { \
/* in non-packed representation we don't care about which NaN is used */ \
(u)->d = DUK_DOUBLE_NAN; \
} while (0)

Definition at line 1512 of file duktape-1.5.2/src-noline/duktape.h.

1512#define DUK_DBLUNION_IS_NORMALIZED_NAN(u) (DUK_ISNAN((u)->d))
1513#define DUK_DBLUNION_IS_NORMALIZED(u) 1 /* all doubles are considered normalized */
1514#define DUK_DBLUNION_SET_NAN(u) do { \
1515 /* in non-packed representation we don't care about which NaN is used */ \

Referenced by duk_js_tonumber(), and duk_push_nan().

◆ DUK_DEBUG_PROTOCOL_VERSION

#define DUK_DEBUG_PROTOCOL_VERSION   1

Definition at line 233 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debugger_attach

#define duk_debugger_attach ( ctx,
read_cb,
write_cb,
peek_cb,
read_flush_cb,
write_flush_cb,
detached_cb,
udata )
Value:
duk_debugger_attach_custom((ctx), (read_cb), (write_cb), (peek_cb), (read_flush_cb), (write_flush_cb), \
NULL, (detached_cb), (udata))
DUK_EXTERNAL_DECL void duk_debugger_attach_custom(duk_context *ctx, duk_debug_read_function read_cb, duk_debug_write_function write_cb, duk_debug_peek_function peek_cb, duk_debug_read_flush_function read_flush_cb, duk_debug_write_flush_function write_flush_cb, duk_debug_request_function request_cb, duk_debug_detached_function detached_cb, void *udata)

Definition at line 1064 of file duktape-1.5.2/src-noline/duktape.h.

1064 */
1065
1066#define duk_debugger_attach(ctx,read_cb,write_cb,peek_cb,read_flush_cb,write_flush_cb,detached_cb,udata) \

Referenced by main().

◆ DUK_DEFPROP_CLEAR_CONFIGURABLE

#define DUK_DEFPROP_CLEAR_CONFIGURABLE   DUK_DEFPROP_HAVE_CONFIGURABLE

Definition at line 321 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_CLEAR_ENUMERABLE

#define DUK_DEFPROP_CLEAR_ENUMERABLE   DUK_DEFPROP_HAVE_ENUMERABLE

Definition at line 319 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_CLEAR_WRITABLE

#define DUK_DEFPROP_CLEAR_WRITABLE   DUK_DEFPROP_HAVE_WRITABLE

Definition at line 317 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_CONFIGURABLE

#define DUK_DEFPROP_CONFIGURABLE   (1 << 2) /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */

◆ DUK_DEFPROP_ENUMERABLE

#define DUK_DEFPROP_ENUMERABLE   (1 << 1) /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */

◆ DUK_DEFPROP_FORCE

#define DUK_DEFPROP_FORCE   (1 << 9) /* force change if possible, may still fail for e.g. virtual properties */

◆ DUK_DEFPROP_HAVE_CONFIGURABLE

#define DUK_DEFPROP_HAVE_CONFIGURABLE   (1 << 5) /* set/clear configurable */

◆ DUK_DEFPROP_HAVE_ENUMERABLE

#define DUK_DEFPROP_HAVE_ENUMERABLE   (1 << 4) /* set/clear enumerable */

◆ DUK_DEFPROP_HAVE_GETTER

#define DUK_DEFPROP_HAVE_GETTER   (1 << 7) /* set getter (given on value stack) */

◆ DUK_DEFPROP_HAVE_SETTER

#define DUK_DEFPROP_HAVE_SETTER   (1 << 8) /* set setter (given on value stack) */

◆ DUK_DEFPROP_HAVE_VALUE

#define DUK_DEFPROP_HAVE_VALUE   (1 << 6) /* set value (given on value stack) */

◆ DUK_DEFPROP_HAVE_WRITABLE

#define DUK_DEFPROP_HAVE_WRITABLE   (1 << 3) /* set/clear writable */

◆ DUK_DEFPROP_SET_CONFIGURABLE

#define DUK_DEFPROP_SET_CONFIGURABLE   (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)

Definition at line 320 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_SET_ENUMERABLE

#define DUK_DEFPROP_SET_ENUMERABLE   (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)

Definition at line 318 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_SET_WRITABLE

#define DUK_DEFPROP_SET_WRITABLE   (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)

Definition at line 316 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_DEFPROP_WRITABLE

#define DUK_DEFPROP_WRITABLE   (1 << 0) /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */

◆ duk_dump_context_filehandle

#define duk_dump_context_filehandle ( ctx,
fh )
Value:
DUK_FPRINTF((fh), "%s\n", duk_safe_to_string(ctx, -1)), \
duk_pop(ctx))
#define duk_safe_to_string(ctx, index)
DUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx)

Definition at line 1045 of file duktape-1.5.2/src-noline/duktape.h.

1045#if defined(DUK_USE_FILE_IO)
1046/* internal use */
1047#define duk_dump_context_filehandle(ctx,fh) \
1048 (duk_push_context_dump((ctx)), \

◆ duk_dump_context_stderr

#define duk_dump_context_stderr ( ctx)     duk_dump_context_filehandle((ctx), DUK_STDERR)

Definition at line 1053 of file duktape-1.5.2/src-noline/duktape.h.

1053#define duk_dump_context_stdout(ctx) \
1054 duk_dump_context_filehandle((ctx), DUK_STDOUT)

◆ duk_dump_context_stdout

#define duk_dump_context_stdout ( ctx)     duk_dump_context_filehandle((ctx), DUK_STDOUT)

Definition at line 1051 of file duktape-1.5.2/src-noline/duktape.h.

1051
1052/* external use */

◆ DUK_ENUM_ARRAY_INDICES_ONLY

#define DUK_ENUM_ARRAY_INDICES_ONLY   (1 << 3) /* only enumerate array indices */

◆ DUK_ENUM_INCLUDE_INTERNAL

#define DUK_ENUM_INCLUDE_INTERNAL   (1 << 1) /* enumerate internal properties (regardless of enumerability) */

Definition at line 285 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_hobject_enumerator_create().

◆ DUK_ENUM_INCLUDE_NONENUMERABLE

#define DUK_ENUM_INCLUDE_NONENUMERABLE   (1 << 0) /* enumerate non-numerable properties in addition to enumerable */

◆ DUK_ENUM_NO_PROXY_BEHAVIOR

#define DUK_ENUM_NO_PROXY_BEHAVIOR   (1 << 5) /* enumerate a proxy object itself without invoking proxy behavior */

◆ DUK_ENUM_OWN_PROPERTIES_ONLY

#define DUK_ENUM_OWN_PROPERTIES_ONLY   (1 << 2) /* don't walk prototype chain, only check own properties */

◆ DUK_ENUM_SORT_ARRAY_INDICES

#define DUK_ENUM_SORT_ARRAY_INDICES   (1 << 4) /* sort array indices, use with DUK_ENUM_ARRAY_INDICES_ONLY */

◆ DUK_ERR_ALLOC_ERROR

#define DUK_ERR_ALLOC_ERROR   53 /* AllocError */ /* XXX: replace with RangeError? */

◆ DUK_ERR_API_ERROR

#define DUK_ERR_API_ERROR   55 /* APIError */ /* XXX: replace with TypeError? */

◆ DUK_ERR_ASSERTION_ERROR

#define DUK_ERR_ASSERTION_ERROR   54 /* AssertionError */ /* XXX: to be removed? */

Definition at line 335 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_error_prototype_from_code().

◆ DUK_ERR_ERROR

◆ DUK_ERR_EVAL_ERROR

#define DUK_ERR_EVAL_ERROR   101 /* EvalError */

◆ DUK_ERR_INTERNAL_ERROR

#define DUK_ERR_INTERNAL_ERROR   52 /* InternalError */ /* XXX: replace with plain Error? */

◆ DUK_ERR_NONE

#define DUK_ERR_NONE   0 /* no error (e.g. from duk_get_error_code()) */

Definition at line 330 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_error_code().

◆ DUK_ERR_RANGE_ERROR

◆ DUK_ERR_REFERENCE_ERROR

#define DUK_ERR_REFERENCE_ERROR   103 /* ReferenceError */

◆ DUK_ERR_SYNTAX_ERROR

#define DUK_ERR_SYNTAX_ERROR   104 /* SyntaxError */

◆ DUK_ERR_TYPE_ERROR

◆ DUK_ERR_UNCAUGHT_ERROR

#define DUK_ERR_UNCAUGHT_ERROR   56 /* UncaughtError */ /* XXX: to be removed? */

Definition at line 337 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_err_longjmp().

◆ DUK_ERR_UNIMPLEMENTED_ERROR

#define DUK_ERR_UNIMPLEMENTED_ERROR   50 /* UnimplementedError */ /* XXX: replace with TypeError? */

◆ DUK_ERR_UNSUPPORTED_ERROR

#define DUK_ERR_UNSUPPORTED_ERROR   51 /* UnsupportedError */ /* XXX: replace with TypeError? */

Definition at line 332 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_ERR_URI_ERROR

◆ duk_error

#define duk_error
Value:
(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
duk_error_stash) /* last value is func pointer, arguments follow in parens */
duk_int_fast32_t duk_int_t
DUK_EXTERNAL void duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt,...)
DUK_EXTERNAL_DECL const char * duk_api_global_filename
DUK_EXTERNAL_DECL duk_int_t duk_api_global_line

Definition at line 434 of file duktape-1.5.2/src-noline/duktape.h.

434 * they make little sense anyway.
435 */
436#define duk_error \
437 (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \

Referenced by create_timer(), create_timer(), do_jxpretty(), do_jxpretty(), do_sandbox_test(), do_sandbox_test(), duk_decode_string_codepage(), expire_timers(), expire_timers(), listen_fd(), listen_fd(), poll_poll(), poll_poll(), socket_connect(), socket_connect(), socket_create_server_socket(), socket_create_server_socket(), wrapped_compile_execute(), and wrapped_compile_execute().

◆ duk_error_va

#define duk_error_va ( ctx,
err_code,
fmt,
ap )    duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))

Definition at line 441 of file duktape-1.5.2/src-noline/duktape.h.

441
442DUK_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));
DUK_EXTERNAL 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)
#define DUK_API_NORETURN(decl)

◆ duk_eval

#define duk_eval ( ctx)     ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))

Definition at line 924 of file duktape-1.5.2/src-noline/duktape.h.

924
925/* plain */

Referenced by eval_raw(), and eval_raw().

◆ duk_eval_file

#define duk_eval_file ( ctx,
path )
Value:
((void) duk_push_string_file_raw((ctx), (path), 0), \
(void) duk_push_string((ctx), (path)), \
(void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL))

Definition at line 993 of file duktape-1.5.2/src-noline/duktape.h.

993
994/* file */
995#define duk_eval_file(ctx,path) \
996 ((void) duk_push_string_file_raw((ctx), (path), 0), \

Referenced by main().

◆ duk_eval_file_noresult

#define duk_eval_file_noresult ( ctx,
path )
Value:
((void) duk_push_string_file_raw((ctx), (path), 0), \
(void) duk_push_string((ctx), (path)), \
(void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))

Definition at line 998 of file duktape-1.5.2/src-noline/duktape.h.

998 (void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL))
999
1000#define duk_eval_file_noresult(ctx,path) \
1001 ((void) duk_push_string_file_raw((ctx), (path), 0), \

◆ duk_eval_lstring

#define duk_eval_lstring ( ctx,
buf,
len )    ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))

Definition at line 968 of file duktape-1.5.2/src-noline/duktape.h.

968
969/* lstring */

◆ duk_eval_lstring_noresult

#define duk_eval_lstring_noresult ( ctx,
buf,
len )    ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))

Definition at line 971 of file duktape-1.5.2/src-noline/duktape.h.

971 ((void) duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
972

◆ duk_eval_noresult

#define duk_eval_noresult ( ctx)     ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))

Definition at line 927 of file duktape-1.5.2/src-noline/duktape.h.

927 ((void) duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))
928

Referenced by main().

◆ duk_eval_string

◆ duk_eval_string_noresult

#define duk_eval_string_noresult ( ctx,
src )    ((void) duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))

Definition at line 946 of file duktape-1.5.2/src-noline/duktape.h.

947

Referenced by duk_hthread_create_builtin_objects(), and main().

◆ DUK_EXEC_ERROR

◆ DUK_EXEC_SUCCESS

◆ DUK_GIT_BRANCH

#define DUK_GIT_BRANCH   "HEAD"

Definition at line 230 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_GIT_COMMIT

#define DUK_GIT_COMMIT   "cad34ae155acb0846545ca6bf2d29f9463b22bbb"

Definition at line 228 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_GIT_DESCRIBE

#define DUK_GIT_DESCRIBE   "v1.5.2"

Definition at line 229 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_HINT_NONE

#define DUK_HINT_NONE
Value:
0 /* prefer number, unless input is a Date, in which
* case prefer string (E5 Section 8.12.8)
*/

Definition at line 279 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__vm_arith_add(), duk_bi_date_constructor(), duk_js_equals_helper(), duk_to_boolean(), duk_to_defaultvalue(), and duk_to_primitive().

◆ DUK_HINT_NUMBER

#define DUK_HINT_NUMBER   2 /* prefer number */

◆ DUK_HINT_STRING

#define DUK_HINT_STRING   1 /* prefer string */

◆ DUK_INVALID_INDEX

◆ duk_is_callable

◆ duk_is_error

#define duk_is_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) != 0)

Definition at line 662 of file duktape-1.5.2/src-noline/duktape.h.

662
DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index)

Referenced by get_stack_raw(), and get_stack_raw().

◆ duk_is_eval_error

#define duk_is_eval_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_EVAL_ERROR)

Definition at line 664 of file duktape-1.5.2/src-noline/duktape.h.

664#define duk_is_error(ctx,index) \
665 (duk_get_error_code((ctx), (index)) != 0)

◆ duk_is_object_coercible

#define duk_is_object_coercible ( ctx,
index )
Value:
#define DUK_TYPE_MASK_STRING
#define DUK_TYPE_MASK_OBJECT
#define DUK_TYPE_MASK_BUFFER
#define DUK_TYPE_MASK_LIGHTFUNC
#define DUK_TYPE_MASK_NUMBER
#define DUK_TYPE_MASK_BOOLEAN
#define DUK_TYPE_MASK_POINTER
DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask)

Definition at line 652 of file duktape-1.5.2/src-noline/duktape.h.

653
654#define duk_is_object_coercible(ctx,index) \
655 duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
#define duk_is_object_coercible(ctx, index)

◆ duk_is_primitive

#define duk_is_primitive ( ctx,
index )
Value:

Definition at line 642 of file duktape-1.5.2/src-noline/duktape.h.

643
644#define duk_is_primitive(ctx,index) \
645 duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_UNDEFINED | \
646 DUK_TYPE_MASK_NULL | \
647 DUK_TYPE_MASK_BOOLEAN | \
648 DUK_TYPE_MASK_NUMBER | \
649 DUK_TYPE_MASK_STRING | \
650 DUK_TYPE_MASK_BUFFER | \
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t index)

Referenced by duk__defaultvalue_coerce_attempt(), and duk_to_defaultvalue().

◆ duk_is_range_error

#define duk_is_range_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_RANGE_ERROR)

Definition at line 666 of file duktape-1.5.2/src-noline/duktape.h.

666#define duk_is_eval_error(ctx,index) \
667 (duk_get_error_code((ctx), (index)) == DUK_ERR_EVAL_ERROR)

◆ duk_is_reference_error

#define duk_is_reference_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_REFERENCE_ERROR)

Definition at line 668 of file duktape-1.5.2/src-noline/duktape.h.

668#define duk_is_range_error(ctx,index) \
669 (duk_get_error_code((ctx), (index)) == DUK_ERR_RANGE_ERROR)

◆ duk_is_syntax_error

#define duk_is_syntax_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_SYNTAX_ERROR)

Definition at line 670 of file duktape-1.5.2/src-noline/duktape.h.

670#define duk_is_reference_error(ctx,index) \
671 (duk_get_error_code((ctx), (index)) == DUK_ERR_REFERENCE_ERROR)

◆ duk_is_type_error

#define duk_is_type_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_TYPE_ERROR)

Definition at line 672 of file duktape-1.5.2/src-noline/duktape.h.

672#define duk_is_syntax_error(ctx,index) \
673 (duk_get_error_code((ctx), (index)) == DUK_ERR_SYNTAX_ERROR)

◆ duk_is_uri_error

#define duk_is_uri_error ( ctx,
index )    (duk_get_error_code((ctx), (index)) == DUK_ERR_URI_ERROR)

Definition at line 674 of file duktape-1.5.2/src-noline/duktape.h.

674#define duk_is_type_error(ctx,index) \
675 (duk_get_error_code((ctx), (index)) == DUK_ERR_TYPE_ERROR)

◆ DUK_LOG_DEBUG

#define DUK_LOG_DEBUG   1

Definition at line 370 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_LOG_ERROR

#define DUK_LOG_ERROR   4

Definition at line 373 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_LOG_FATAL

#define DUK_LOG_FATAL   5

Definition at line 374 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_LOG_INFO

#define DUK_LOG_INFO   2

Definition at line 371 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_LOG_TRACE

#define DUK_LOG_TRACE   0

Definition at line 369 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_LOG_WARN

#define DUK_LOG_WARN   3

Definition at line 372 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_pcompile

#define duk_pcompile ( ctx,
flags )    (duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))

Definition at line 939 of file duktape-1.5.2/src-noline/duktape.h.

939 ((void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
940

◆ duk_pcompile_file

#define duk_pcompile_file ( ctx,
flags,
path )
Value:
(void) duk_push_string((ctx), (path)), \
duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags) | DUK_COMPILE_SAFE))
#define DUK_STRING_PUSH_SAFE

Definition at line 1018 of file duktape-1.5.2/src-noline/duktape.h.

1018 (void) duk_compile_raw((ctx), NULL, 0, 3 /*args*/ | (flags)))
1019
1020#define duk_pcompile_file(ctx,flags,path) \
1021 ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
#define duk_pcompile_file(ctx, flags, path)

◆ duk_pcompile_lstring

#define duk_pcompile_lstring ( ctx,
flags,
buf,
len )    (duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))

Definition at line 986 of file duktape-1.5.2/src-noline/duktape.h.

986 ((void) duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))
987

◆ duk_pcompile_lstring_filename

#define duk_pcompile_lstring_filename ( ctx,
flags,
buf,
len )    (duk_compile_raw((ctx), buf, len, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))

Definition at line 989 of file duktape-1.5.2/src-noline/duktape.h.

989 (duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))
990

◆ duk_pcompile_string

#define duk_pcompile_string ( ctx,
flags,
src )    (duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))

Definition at line 961 of file duktape-1.5.2/src-noline/duktape.h.

961 ((void) duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))
962

◆ duk_pcompile_string_filename

#define duk_pcompile_string_filename ( ctx,
flags,
src )    (duk_compile_raw((ctx), (src), 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))

Definition at line 964 of file duktape-1.5.2/src-noline/duktape.h.

965

◆ duk_peval

#define duk_peval ( ctx)     (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))

Definition at line 930 of file duktape-1.5.2/src-noline/duktape.h.

931

◆ duk_peval_file

#define duk_peval_file ( ctx,
path )
Value:
(void) duk_push_string((ctx), (path)), \
duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))

Definition at line 1003 of file duktape-1.5.2/src-noline/duktape.h.

1003 (void) duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT))
1004
1005#define duk_peval_file(ctx,path) \
1006 ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \

Referenced by main().

◆ duk_peval_file_noresult

#define duk_peval_file_noresult ( ctx,
path )
Value:
(void) duk_push_string((ctx), (path)), \
duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT))

Definition at line 1008 of file duktape-1.5.2/src-noline/duktape.h.

1008 duk_eval_raw((ctx), NULL, 0, 3 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE))
1009
1010#define duk_peval_file_noresult(ctx,path) \
1011 ((void) duk_push_string_file_raw((ctx), (path), DUK_STRING_PUSH_SAFE), \
#define duk_peval_file_noresult(ctx, path)

◆ duk_peval_lstring

#define duk_peval_lstring ( ctx,
buf,
len )    (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))

Definition at line 974 of file duktape-1.5.2/src-noline/duktape.h.

975

◆ duk_peval_lstring_noresult

#define duk_peval_lstring_noresult ( ctx,
buf,
len )    (duk_eval_raw((ctx), buf, len, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))

Definition at line 977 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_peval_noresult

#define duk_peval_noresult ( ctx)     (duk_eval_raw((ctx), NULL, 0, 2 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))

Definition at line 933 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_peval_string

#define duk_peval_string ( ctx,
src )    (duk_eval_raw((ctx), (src), 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))

◆ duk_peval_string_noresult

#define duk_peval_string_noresult ( ctx,
src )    (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))

◆ duk_push_buffer

#define duk_push_buffer ( ctx,
size,
dynamic )    duk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)

Definition at line 568 of file duktape-1.5.2/src-noline/duktape.h.

569
unsigned int duk_small_uint_t
DUK_EXTERNAL_DECL void * duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags)

Referenced by duk_bi_buffer_constructor(), and duk_to_buffer_raw().

◆ duk_push_dynamic_buffer

#define duk_push_dynamic_buffer ( ctx,
size )    duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)

Definition at line 572 of file duktape-1.5.2/src-noline/duktape.h.

572#define duk_push_fixed_buffer(ctx,size) \
573 duk_push_buffer_raw((ctx), (size), 0 /*flags*/)

Referenced by duk__init_func_valstack_slots(), duk__js_compile_raw(), duk__realloc_props(), duk_base64_decode(), duk_bw_init_pushbuf(), duk_hobject_pc2line_pack(), and duk_push_vsprintf().

◆ duk_push_error_object

#define duk_push_error_object
Value:
(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \
duk_push_error_object_stash) /* last value is func pointer, arguments follow in parens */
DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt,...)

Definition at line 552 of file duktape-1.5.2/src-noline/duktape.h.

553/* Note: parentheses are required so that the comma expression works in assignments. */
554#define duk_push_error_object \
555 (duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \

◆ duk_push_error_object_va

#define duk_push_error_object_va ( ctx,
err_code,
fmt,
ap )    duk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))

Definition at line 559 of file duktape-1.5.2/src-noline/duktape.h.

559
560DUK_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);
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)

◆ duk_push_external_buffer

#define duk_push_external_buffer ( ctx)     ((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))

Definition at line 574 of file duktape-1.5.2/src-noline/duktape.h.

574#define duk_push_dynamic_buffer(ctx,size) \
575 duk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)

◆ duk_push_fixed_buffer

◆ duk_push_string_file

#define duk_push_string_file ( ctx,
path )    duk_push_string_file_raw((ctx), (path), 0)

Definition at line 521 of file duktape-1.5.2/src-noline/duktape.h.

521
522DUK_EXTERNAL_DECL const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags);
duk_uint_fast32_t duk_uint_t

◆ duk_push_thread

#define duk_push_thread ( ctx)     duk_push_thread_raw((ctx), 0 /*flags*/)

Definition at line 538 of file duktape-1.5.2/src-noline/duktape.h.

539
DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags)

Referenced by duk_bi_thread_constructor().

◆ duk_push_thread_new_globalenv

#define duk_push_thread_new_globalenv ( ctx)     duk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)

Definition at line 541 of file duktape-1.5.2/src-noline/duktape.h.

541 duk_push_thread_raw((ctx), 0 /*flags*/)
542

◆ duk_require_callable

#define duk_require_callable ( ctx,
index )    duk_require_function((ctx), (index))

Definition at line 721 of file duktape-1.5.2/src-noline/duktape.h.

DUK_EXTERNAL_DECL duk_context * duk_require_context(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t index)

Referenced by duk_bi_array_prototype_iter_shared().

◆ duk_require_object_coercible

#define duk_require_object_coercible ( ctx,
index )
Value:

Definition at line 725 of file duktape-1.5.2/src-noline/duktape.h.

726
727#define duk_require_object_coercible(ctx,index) \
728 ((void) duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
729 DUK_TYPE_MASK_NUMBER | \
730 DUK_TYPE_MASK_STRING | \
731 DUK_TYPE_MASK_OBJECT | \
732 DUK_TYPE_MASK_BUFFER | \
733 DUK_TYPE_MASK_POINTER | \
DUK_EXTERNAL_DECL void * duk_require_heapptr(duk_context *ctx, duk_idx_t index)

Referenced by duk_bi_object_setprototype_shared().

◆ duk_require_type_mask

#define duk_require_type_mask ( ctx,
index,
mask )    ((void) duk_check_type_mask((ctx), (index), (mask) | DUK_TYPE_MASK_THROW))

◆ DUK_RET_ALLOC_ERROR

#define DUK_RET_ALLOC_ERROR   (-DUK_ERR_ALLOC_ERROR)

◆ DUK_RET_API_ERROR

#define DUK_RET_API_ERROR   (-DUK_ERR_API_ERROR)

◆ DUK_RET_ASSERTION_ERROR

#define DUK_RET_ASSERTION_ERROR   (-DUK_ERR_ASSERTION_ERROR)

◆ DUK_RET_ERROR

#define DUK_RET_ERROR   (-DUK_ERR_ERROR)

◆ DUK_RET_EVAL_ERROR

#define DUK_RET_EVAL_ERROR   (-DUK_ERR_EVAL_ERROR)

◆ DUK_RET_INTERNAL_ERROR

#define DUK_RET_INTERNAL_ERROR   (-DUK_ERR_INTERNAL_ERROR)

◆ DUK_RET_RANGE_ERROR

◆ DUK_RET_REFERENCE_ERROR

#define DUK_RET_REFERENCE_ERROR   (-DUK_ERR_REFERENCE_ERROR)

◆ DUK_RET_SYNTAX_ERROR

#define DUK_RET_SYNTAX_ERROR   (-DUK_ERR_SYNTAX_ERROR)

◆ DUK_RET_TYPE_ERROR

◆ DUK_RET_UNCAUGHT_ERROR

#define DUK_RET_UNCAUGHT_ERROR   (-DUK_ERR_UNCAUGHT_ERROR)

◆ DUK_RET_UNIMPLEMENTED_ERROR

#define DUK_RET_UNIMPLEMENTED_ERROR   (-DUK_ERR_UNIMPLEMENTED_ERROR)

◆ DUK_RET_UNSUPPORTED_ERROR

◆ DUK_RET_URI_ERROR

#define DUK_RET_URI_ERROR   (-DUK_ERR_URI_ERROR)

◆ duk_safe_to_string

#define duk_safe_to_string ( ctx,
index )    duk_safe_to_lstring((ctx), (index), NULL)

Definition at line 772 of file duktape-1.5.2/src-noline/duktape.h.

772/* safe variants of a few coercion operations */
DUK_EXTERNAL_DECL const char * duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)

Referenced by duk_push_context_dump(), main(), main(), print_pop_error(), and print_pop_error().

◆ DUK_SINGLE_FILE

#define DUK_SINGLE_FILE

Definition at line 124 of file duktape-1.5.2/src-noline/duktape.h.

◆ DUK_STRING_PUSH_SAFE

#define DUK_STRING_PUSH_SAFE   (1 << 0) /* no error if file does not exist */

◆ DUK_THREAD_NEW_GLOBAL_ENV

#define DUK_THREAD_NEW_GLOBAL_ENV   (1 << 0) /* create a new global environment */

Definition at line 324 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_push_thread_raw().

◆ duk_to_buffer

#define duk_to_buffer ( ctx,
index,
out_size )    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)

Definition at line 763 of file duktape-1.5.2/src-noline/duktape.h.

763#define DUK_BUF_MODE_DONTCARE 2 /* internal: don't care about fixed/dynamic nature */
764

Referenced by duk_bi_nodejs_buffer_constructor(), socket_write(), socket_write(), wrapped_compile_execute(), and wrapped_compile_execute().

◆ duk_to_dynamic_buffer

#define duk_to_dynamic_buffer ( ctx,
index,
out_size )    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DYNAMIC)

Definition at line 767 of file duktape-1.5.2/src-noline/duktape.h.

767#define duk_to_fixed_buffer(ctx,index,out_size) \
768 duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)

◆ duk_to_fixed_buffer

#define duk_to_fixed_buffer ( ctx,
index,
out_size )    duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)

Definition at line 765 of file duktape-1.5.2/src-noline/duktape.h.

765#define duk_to_buffer(ctx,index,out_size) \
766 duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)

Referenced by duk_hobject_pc2line_pack().

◆ DUK_TYPE_BOOLEAN

#define DUK_TYPE_BOOLEAN   3 /* Ecmascript boolean: 0 or 1 */

Definition at line 256 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type().

◆ DUK_TYPE_BUFFER

#define DUK_TYPE_BUFFER   7 /* fixed or dynamic, garbage collected byte buffer */

◆ DUK_TYPE_LIGHTFUNC

#define DUK_TYPE_LIGHTFUNC   9 /* lightweight function pointer */

Definition at line 262 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk__error_getter_helper(), and duk_get_type().

◆ DUK_TYPE_MASK_BOOLEAN

#define DUK_TYPE_MASK_BOOLEAN   (1 << DUK_TYPE_BOOLEAN)

◆ DUK_TYPE_MASK_BUFFER

◆ DUK_TYPE_MASK_LIGHTFUNC

◆ DUK_TYPE_MASK_NONE

#define DUK_TYPE_MASK_NONE   (1 << DUK_TYPE_NONE)

Definition at line 266 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type_mask().

◆ DUK_TYPE_MASK_NULL

#define DUK_TYPE_MASK_NULL   (1 << DUK_TYPE_NULL)

◆ DUK_TYPE_MASK_NUMBER

#define DUK_TYPE_MASK_NUMBER   (1 << DUK_TYPE_NUMBER)

◆ DUK_TYPE_MASK_OBJECT

◆ DUK_TYPE_MASK_POINTER

#define DUK_TYPE_MASK_POINTER   (1 << DUK_TYPE_POINTER)

◆ DUK_TYPE_MASK_STRING

#define DUK_TYPE_MASK_STRING   (1 << DUK_TYPE_STRING)

◆ DUK_TYPE_MASK_THROW

#define DUK_TYPE_MASK_THROW   (1 << 10) /* internal flag value: throw if mask doesn't match */

Definition at line 276 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_check_type_mask().

◆ DUK_TYPE_MASK_UNDEFINED

◆ DUK_TYPE_MAX

#define DUK_TYPE_MAX   9

Definition at line 263 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type_mask().

◆ DUK_TYPE_MIN

#define DUK_TYPE_MIN   0

Definition at line 252 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type_mask().

◆ DUK_TYPE_NONE

#define DUK_TYPE_NONE   0 /* no value, e.g. invalid index */

Definition at line 253 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_bi_buffer_constructor(), and duk_get_type().

◆ DUK_TYPE_NULL

#define DUK_TYPE_NULL   2 /* Ecmascript null */

Definition at line 255 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type().

◆ DUK_TYPE_NUMBER

#define DUK_TYPE_NUMBER   4 /* Ecmascript number: double */

◆ DUK_TYPE_OBJECT

#define DUK_TYPE_OBJECT   6 /* Ecmascript object: includes objects, arrays, functions, threads */

◆ DUK_TYPE_POINTER

#define DUK_TYPE_POINTER   8 /* raw void pointer */

Definition at line 261 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type().

◆ DUK_TYPE_STRING

#define DUK_TYPE_STRING   5 /* Ecmascript string: CESU-8 / extended UTF-8 encoded */

◆ DUK_TYPE_UNDEFINED

#define DUK_TYPE_UNDEFINED   1 /* Ecmascript undefined */

Definition at line 254 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by duk_get_type().

◆ DUK_VARARGS

◆ DUK_VERSION

#define DUK_VERSION   10502L

Definition at line 221 of file duktape-1.5.2/src-noline/duktape.h.

Referenced by mg_get_system_info().

◆ duk_xcopy_top

#define duk_xcopy_top ( to_ctx,
from_ctx,
count )    duk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)

Definition at line 493 of file duktape-1.5.2/src-noline/duktape.h.

493#define duk_xmove_top(to_ctx,from_ctx,count) \
494 duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)

◆ duk_xmove_top

#define duk_xmove_top ( to_ctx,
from_ctx,
count )    duk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)

Definition at line 491 of file duktape-1.5.2/src-noline/duktape.h.

491DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);
492
DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy)

Typedef Documentation

◆ duk_alloc_function

typedef void *(* duk_alloc_function) (void *udata, duk_size_t size)

Definition at line 178 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_c_function

typedef duk_ret_t(* duk_c_function) (duk_context *ctx)

Definition at line 177 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_detached_function

typedef void(* duk_debug_detached_function) (void *udata)

Definition at line 191 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_peek_function

typedef duk_size_t(* duk_debug_peek_function) (void *udata)

Definition at line 187 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_read_flush_function

typedef void(* duk_debug_read_flush_function) (void *udata)

Definition at line 188 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_read_function

typedef duk_size_t(* duk_debug_read_function) (void *udata, char *buffer, duk_size_t length)

Definition at line 185 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_request_function

typedef duk_idx_t(* duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues)

Definition at line 190 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_write_flush_function

typedef void(* duk_debug_write_flush_function) (void *udata)

Definition at line 189 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_debug_write_function

typedef duk_size_t(* duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length)

Definition at line 186 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_decode_char_function

typedef void(* duk_decode_char_function) (void *udata, duk_codepoint_t codepoint)

Definition at line 182 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_double_union

typedef union duk_double_union duk_double_union

Definition at line 1257 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_fatal_function

typedef void(* duk_fatal_function) (duk_context *ctx, duk_errcode_t code, const char *msg)

Definition at line 181 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_free_function

typedef void(* duk_free_function) (void *udata, void *ptr)

Definition at line 180 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_function_list_entry

typedef struct duk_function_list_entry duk_function_list_entry

Definition at line 174 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_map_char_function

typedef duk_codepoint_t(* duk_map_char_function) (void *udata, duk_codepoint_t codepoint)

Definition at line 183 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_memory_functions

typedef struct duk_memory_functions duk_memory_functions

Definition at line 173 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_number_list_entry

typedef struct duk_number_list_entry duk_number_list_entry

Definition at line 175 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_realloc_function

typedef void *(* duk_realloc_function) (void *udata, void *ptr, duk_size_t size)

Definition at line 179 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_safe_call_function

typedef duk_ret_t(* duk_safe_call_function) (duk_context *ctx)

Definition at line 184 of file duktape-1.5.2/src-noline/duktape.h.

Function Documentation

◆ duk_alloc()

DUK_EXTERNAL_DECL void * duk_alloc ( duk_context * ctx,
duk_size_t size )

Definition at line 14191 of file duktape-1.5.2/src-noline/duktape.c.

14192 {
14193 duk_hthread *thr = (duk_hthread *) ctx;
14194
14196
14197 DUK_FREE_RAW(thr->heap, ptr);
#define DUK_ASSERT_CTX_VALID(ctx)
#define DUK_FREE_RAW(heap, ptr)

◆ duk_alloc_raw()

DUK_EXTERNAL_DECL void * duk_alloc_raw ( duk_context * ctx,
duk_size_t size )

Definition at line 14167 of file duktape-1.5.2/src-noline/duktape.c.

14169 {
14170 va_list ap;
14171
14173

◆ DUK_API_NORETURN() [1/5]

DUK_API_NORETURN ( DUK_EXTERNAL_DECL void duk_error_rawduk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt,...)

◆ DUK_API_NORETURN() [2/5]

DUK_API_NORETURN ( DUK_EXTERNAL_DECL void duk_error_stashduk_context *ctx, duk_errcode_t err_code, const char *fmt,...)

◆ DUK_API_NORETURN() [3/5]

DUK_API_NORETURN ( DUK_EXTERNAL_DECL void duk_error_va_rawduk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap)

◆ DUK_API_NORETURN() [4/5]

DUK_API_NORETURN ( DUK_EXTERNAL_DECL void duk_fatalduk_context *ctx, duk_errcode_t err_code, const char *err_msg)

◆ DUK_API_NORETURN() [5/5]

DUK_API_NORETURN ( DUK_EXTERNAL_DECL void duk_throwduk_context *ctx)

◆ duk_base64_decode()

DUK_EXTERNAL_DECL void duk_base64_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13289 of file duktape-1.5.2/src-noline/duktape.c.

13289 {
13290 goto type_error;
13291 }
13292 dstlen = (srclen + 2) / 3 * 4;
13293 dst = (duk_uint8_t *) duk_push_fixed_buffer(ctx, dstlen);
13294
13295 duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst);
13296
13297 ret = duk_to_string(ctx, -1);
13298 duk_replace(ctx, index);
13299 return ret;
13300
13301 type_error:
13303 return NULL; /* never here */
13304}
13305
13307 duk_hthread *thr = (duk_hthread *) ctx;
13308 const duk_uint8_t *src;
13309 duk_size_t srclen;
13310 duk_size_t dstlen;
13311 duk_uint8_t *dst;
13312 duk_uint8_t *dst_final;
13313 duk_bool_t retval;
13314
13316
13317 /* XXX: optimize for buffer inputs: no need to coerce to a string
13318 * which causes an unnecessary interning.
13319 */
13320
13322 src = duk__prep_codec_arg(ctx, index, &srclen);
13323
13324 /* Computation must not wrap, only srclen + 3 is at risk of
13325 * wrapping because after that the number gets smaller.
13326 * This limit works for 32-bit size_t:
13327 * 0x100000000 - 3 - 1 = 4294967292
13328 */
13329 if (srclen > 4294967292UL) {
13330 goto type_error;
13331 }
DUK_EXTERNAL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index)
#define DUK_ERROR_TYPE(thr, msg)
DUK_LOCAL const duk_uint8_t * duk__prep_codec_arg(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index)
DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst)
DUK_EXTERNAL const char * duk_to_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t index)
#define DUK_STR_ENCODE_FAILED
#define duk_push_fixed_buffer(ctx, size)

◆ duk_base64_encode()

DUK_EXTERNAL_DECL const char * duk_base64_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13249 of file duktape-1.5.2/src-noline/duktape.c.

13250 {
13251 /* Here we'd have the option of decoding unpadded base64
13252 * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not
13253 * accepted.
13254 */
13255 goto error;
13256 }
13257
13258 *out_dst_final = dst;
13259 return 1;
13260
13261 error:
13262 return 0;
13263}
13264#endif /* DUK_USE_BASE64_FASTPATH */
13265
13267 duk_hthread *thr = (duk_hthread *) ctx;
13268 const duk_uint8_t *src;
13269 duk_size_t srclen;
13270 duk_size_t dstlen;
13271 duk_uint8_t *dst;
13272 const char *ret;
13273
13275
13276 /* XXX: optimize for string inputs: no need to coerce to a buffer
13277 * which makes a copy of the input.
13278 */
13279
13281 src = duk__prep_codec_arg(ctx, index, &srclen);
13282 /* Note: for srclen=0, src may be NULL */
13283
13284 /* Computation must not wrap; this limit works for 32-bit size_t:
13285 * >>> srclen = 3221225469
13286 * >>> '%x' % ((srclen + 2) / 3 * 4)
13287 * 'fffffffc'
DUK_EXTERNAL const char * duk_base64_encode(duk_context *ctx, duk_idx_t index)
static void error(LoadState *S, const char *why)

◆ duk_call()

DUK_EXTERNAL_DECL void duk_call ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12362 of file duktape-1.5.2/src-noline/duktape.c.

12365 : %!T", (duk_tval *) duk_get_tval(ctx, -1)));
12366
12367 /* [... key arg1 ... argN func] */
12368
12369 duk_replace(ctx, -nargs - 2);
12370
12371 /* [... func arg1 ... argN] */
12372
12373 duk_dup(ctx, normalized_obj_index);
12374 duk_insert(ctx, -nargs - 1);
12375
12376 /* [... func this arg1 ... argN] */
12377}
12378
12379DUK_EXTERNAL void duk_call(duk_context *ctx, duk_idx_t nargs) {
12380 duk_hthread *thr = (duk_hthread *) ctx;
12381 duk_small_uint_t call_flags;
12382 duk_idx_t idx_func;
12383
12384 DUK_ASSERT_CTX_VALID(ctx);
12385 DUK_ASSERT(thr != NULL);
12386
12387 idx_func = duk_get_top(ctx) - nargs - 1;

◆ duk_call_method()

DUK_EXTERNAL_DECL void duk_call_method ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12389 of file duktape-1.5.2/src-noline/duktape.c.

12406 {
12407 duk_hthread *thr = (duk_hthread *) ctx;
12408 duk_small_uint_t call_flags;

◆ duk_call_prop()

DUK_EXTERNAL_DECL void duk_call_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_idx_t nargs )

Definition at line 12410 of file duktape-1.5.2/src-noline/duktape.c.

12415 {
12416 /* note that we can't reliably pop anything here */
12418 }
12419
12420 call_flags = 0; /* not protected, respect reclimit, not constructor */
12421
12422 duk_handle_call_unprotected(thr, /* thread */
12423 nargs, /* num_stack_args */
12424 call_flags); /* call_flags */
12425}
#define DUK_STR_INVALID_CALL_ARGS
#define DUK_ERROR_API(thr, msg)
DUK_INTERNAL_DECL void duk_handle_call_unprotected(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)

◆ duk_char_code_at()

DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at ( duk_context * ctx,
duk_idx_t index,
duk_size_t char_offset )

Definition at line 19844 of file duktape-1.5.2/src-noline/duktape.c.

19848 : p_start=%p, p_end=%p, q_start=%p, q_end=%p",
19849 (const void *) p_start, (const void *) p_end,
19850 (const void *) q_start, (const void *) q_end));
19851
19852 if (q_start == p_start && q_end == p_end) {
19853 DUK_DDD(DUK_DDDPRINT("nothing was trimmed: avoid interning (hashing etc)"));
19854 return;
19855 }
19856
19857 duk_push_lstring(ctx, (const char *) q_start, (duk_size_t) (q_end - q_start));
19858 duk_replace(ctx, index);
19859}
19860
19861DUK_EXTERNAL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset) {
19862 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_check_stack()

DUK_EXTERNAL_DECL duk_bool_t duk_check_stack ( duk_context * ctx,
duk_idx_t extra )

Definition at line 15590 of file duktape-1.5.2/src-noline/duktape.c.

15596 {
15598 } else {
15599 return 0;
15600 }
15601 }
15602
15603 DUK_DDD(DUK_DDDPRINT("valstack resize successful"));
15604 return 1;
15605}
15606
15608 duk_hthread *thr = (duk_hthread *) ctx;
15609 duk_size_t min_new_size;
15610
#define DUK_ERROR_ALLOC_DEFMSG(thr)
DUK_EXTERNAL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra)

◆ duk_check_stack_top()

DUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top ( duk_context * ctx,
duk_idx_t top )

Definition at line 15634 of file duktape-1.5.2/src-noline/duktape.c.

15636 {
15637 /* Clamping to zero makes the API more robust to calling code
15638 * calculation errors.
15639 */
15640 extra = 0;
15641 }
15642
15643 min_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;
15644 (void) duk_valstack_resize_raw(ctx,
15645 min_new_size, /* min_new_size */
15646 0 /* no shrink */ | /* flags */
15647 0 /* no compact */ |
15649}
15650
15652 duk_size_t min_new_size;
#define DUK_VSRESIZE_FLAG_THROW
DUK_INTERNAL_DECL duk_bool_t duk_valstack_resize_raw(duk_context *ctx, duk_size_t min_new_size, duk_small_uint_t flags)
DUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top)
#define DUK_VALSTACK_INTERNAL_EXTRA

◆ duk_check_type()

DUK_EXTERNAL_DECL duk_bool_t duk_check_type ( duk_context * ctx,
duk_idx_t index,
duk_int_t type )

Definition at line 17541 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_check_type_mask()

DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask ( duk_context * ctx,
duk_idx_t index,
duk_uint_t mask )

Definition at line 17585 of file duktape-1.5.2/src-noline/duktape.c.

17586 :
17587 return DUK_TYPE_MASK_POINTER;
17588 case DUK_TAG_LIGHTFUNC:
17590#if defined(DUK_USE_FASTINT)
17591 case DUK_TAG_FASTINT:
17592#endif
17593 default:
17594 /* Note: number has no explicit tag (in 8-byte representation) */
17597 return DUK_TYPE_MASK_NUMBER;
17598 }
#define DUK_TVAL_IS_NUMBER(tv)
#define DUK_TVAL_IS_UNUSED(tv)

◆ duk_compact()

DUK_EXTERNAL_DECL void duk_compact ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14704 of file duktape-1.5.2/src-noline/duktape.c.

14705 :
14707 return;
14708
14709 fail_not_callable:
14711 return;
14712}
14713
14714/*
14715 * Object related
#define DUK_STR_INVALID_DESCRIPTOR

◆ duk_compile_raw()

DUK_EXTERNAL_DECL duk_int_t duk_compile_raw ( duk_context * ctx,
const char * src_buffer,
duk_size_t src_length,
duk_uint_t flags )

Definition at line 13668 of file duktape-1.5.2/src-noline/duktape.c.

13685 {
13686 duk__compile_raw_args comp_args_alloc;
13687 duk__compile_raw_args *comp_args = &comp_args_alloc;
13688
13690
13691 if ((flags & DUK_COMPILE_STRLEN) && (src_buffer != NULL)) {
13692 /* String length is computed here to avoid multiple evaluation
13693 * of a macro argument in the calling side.
13694 */
13695 src_length = DUK_STRLEN(src_buffer);
13696 }
13697
13698 comp_args->src_buffer = (const duk_uint8_t *) src_buffer;
13699 comp_args->src_length = src_length;
13700 comp_args->flags = flags;
13701 duk_push_pointer(ctx, (void *) comp_args);
13702
13703 /* [ ... source? filename? &comp_args ] (depends on flags) */
13704
13705 if (flags & DUK_COMPILE_SAFE) {
13706 duk_int_t rc;
13707 duk_int_t nargs;
13708 duk_int_t nrets = 1;
13709
13710 /* Arguments can be: [ source? filename? &comp_args] so that
13711 * nargs is 1 to 3. Call site encodes the correct nargs count
DUK_EXTERNAL void duk_push_pointer(duk_context *ctx, void *val)

◆ duk_concat()

DUK_EXTERNAL_DECL void duk_concat ( duk_context * ctx,
duk_idx_t count )

Definition at line 19640 of file duktape-1.5.2/src-noline/duktape.c.

19641 {
19642 duk_replace(ctx, -((duk_idx_t) count) - 1); /* overwrite str1 */
19643 duk_pop_n(ctx, count-1);
19644 }
DUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count)

◆ duk_config_buffer()

DUK_EXTERNAL_DECL void duk_config_buffer ( duk_context * ctx,
duk_idx_t index,
void * ptr,
duk_size_t len )

Definition at line 11581 of file duktape-1.5.2/src-noline/duktape.c.

11589 {
11590 *out_size = sz;
11591 }
11594
11595 return ptr;
11596}
11597
#define DUK_HBUFFER_DYNAMIC_SET_SIZE(x, v)
#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap, x)

◆ duk_copy()

DUK_EXTERNAL_DECL void duk_copy ( duk_context * ctx,
duk_idx_t from_index,
duk_idx_t to_index )

Definition at line 15803 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_create_heap()

DUK_EXTERNAL_DECL duk_context * duk_create_heap ( duk_alloc_function alloc_func,
duk_realloc_function realloc_func,
duk_free_function free_func,
void * heap_udata,
duk_fatal_function fatal_handler )

Definition at line 13982 of file duktape-1.5.2/src-noline/duktape.c.

13985 {
13986 /* Treat like debugger statement: nop */
13988 DUK_UNREF(ctx);
13989}
13990
13991#endif /* DUK_USE_DEBUGGER_SUPPORT */
13992/*
13993 * Heap creation and destruction
13994 */
13995
13996/* include removed: duk_internal.h */
13997
14000 duk_realloc_function realloc_func,
14001 duk_free_function free_func,
14002 void *heap_udata,
14003 duk_fatal_function fatal_handler) {
14004 duk_heap *heap = NULL;
14005 duk_context *ctx;
14006
14007 /* Assume that either all memory funcs are NULL or non-NULL, mixed
14008 * cases will now be unsafe.
14009 */
14010
14011 /* XXX: just assert non-NULL values here and make caller arguments
14012 * do the defaulting to the default implementations (smaller code)?
14013 */
14014
14015 if (!alloc_func) {
14016 DUK_ASSERT(realloc_func == NULL);
14017 DUK_ASSERT(free_func == NULL);
14018#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
14019 alloc_func = duk_default_alloc_function;
14020 realloc_func = duk_default_realloc_function;
14021 free_func = duk_default_free_function;
14022#else
14023 DUK_D(DUK_DPRINT("no allocation functions given and no default providers"));
14024 return NULL;
14025#endif
14026 } else {
14027 DUK_ASSERT(realloc_func != NULL);
14028 DUK_ASSERT(free_func != NULL);
14029 }
14030
14031 if (!fatal_handler) {
DUK_INTERNAL_DECL void duk_default_free_function(void *udata, void *ptr)
DUK_INTERNAL_DECL void * duk_default_alloc_function(void *udata, duk_size_t size)
DUK_EXTERNAL duk_context * duk_create_heap(duk_alloc_function alloc_func, duk_realloc_function realloc_func, duk_free_function free_func, void *heap_udata, duk_fatal_function fatal_handler)
DUK_INTERNAL_DECL void * duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize)
void *(* duk_alloc_function)(void *udata, duk_size_t size)
void(* duk_fatal_function)(duk_context *ctx, duk_errcode_t code, const char *msg)
void(* duk_free_function)(void *udata, void *ptr)
void *(* duk_realloc_function)(void *udata, void *ptr, duk_size_t size)

◆ duk_debugger_attach_custom()

DUK_EXTERNAL_DECL void duk_debugger_attach_custom ( duk_context * ctx,
duk_debug_read_function read_cb,
duk_debug_write_function write_cb,
duk_debug_peek_function peek_cb,
duk_debug_read_flush_function read_flush_cb,
duk_debug_write_flush_function write_flush_cb,
duk_debug_request_function request_cb,
duk_debug_detached_function detached_cb,
void * udata )

Definition at line 13920 of file duktape-1.5.2/src-noline/duktape.c.

13923 {
13924 DUK_HEAP_SET_PAUSED(thr->heap);
13925
13926 /* Pause on the next opcode executed. This is always safe to do even
13927 * inside the debugger message loop: the interrupt counter will be reset
13928 * to its proper value when the message loop exits.
13929 */
13930 thr->interrupt_init = 1;
13931 thr->interrupt_counter = 0;
13932 }
13933}
13934
13935#else /* DUK_USE_DEBUGGER_SUPPORT */
13936
13939 duk_debug_write_function write_cb,
DUK_EXTERNAL void duk_debugger_attach_custom(duk_context *ctx, duk_debug_read_function read_cb, duk_debug_write_function write_cb, duk_debug_peek_function peek_cb, duk_debug_read_flush_function read_flush_cb, duk_debug_write_flush_function write_flush_cb, duk_debug_request_function request_cb, duk_debug_detached_function detached_cb, void *udata)
duk_size_t(* duk_debug_read_function)(void *udata, char *buffer, duk_size_t length)
duk_size_t(* duk_debug_write_function)(void *udata, const char *buffer, duk_size_t length)

◆ duk_debugger_cooperate()

DUK_EXTERNAL_DECL void duk_debugger_cooperate ( duk_context * ctx)

Definition at line 13946 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_debugger_detach()

DUK_EXTERNAL_DECL void duk_debugger_detach ( duk_context * ctx)

Definition at line 13941 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_debugger_notify()

DUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify ( duk_context * ctx,
duk_idx_t nvalues )

Definition at line 13952 of file duktape-1.5.2/src-noline/duktape.c.

13958 {
13960 DUK_ERROR_API((duk_hthread *) ctx, "no debugger support");
13961}
13962
13964 /* nop */
13966 DUK_UNREF(ctx);
DUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx)

◆ duk_debugger_pause()

DUK_EXTERNAL_DECL void duk_debugger_pause ( duk_context * ctx)

Definition at line 13968 of file duktape-1.5.2/src-noline/duktape.c.

13969 {
13970 duk_idx_t top;
13971

◆ duk_decode_string()

DUK_EXTERNAL_DECL void duk_decode_string ( duk_context * ctx,
duk_idx_t index,
duk_decode_char_function callback,
void * udata )

Definition at line 19656 of file duktape-1.5.2/src-noline/duktape.c.

19657 {
19659
19660 duk__concat_and_join_helper(ctx, count, 0 /*is_join*/);
19661}
19662
19663DUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count) {
19665
19666 duk__concat_and_join_helper(ctx, count, 1 /*is_join*/);
19667}
19668
19669/* XXX: could map/decode be unified with duk_unicode_support.c code?
19670 * Case conversion needs also the character surroundings though.
19671 */
19672
19674 duk_hthread *thr = (duk_hthread *) ctx;
19675 duk_hstring *h_input;
19676 const duk_uint8_t *p, *p_start, *p_end;
19677 duk_codepoint_t cp;
19678
DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata)
DUK_LOCAL void duk__concat_and_join_helper(duk_context *ctx, duk_idx_t count_in, duk_bool_t is_join)
DUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count)
void(* duk_decode_char_function)(void *udata, duk_codepoint_t codepoint)

◆ duk_def_prop()

DUK_EXTERNAL_DECL void duk_def_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_uint_t flags )

Definition at line 14612 of file duktape-1.5.2/src-noline/duktape.c.

14621 {
14622 duk_hthread *thr = (duk_hthread *) ctx;
14623 duk_hobject *obj = duk_require_hobject(ctx, obj_index);
14625 duk_hobject_define_accessor_internal(thr, obj, DUK_HTHREAD_GET_STRING(thr, stridx), thrower, thrower, desc_flags);
14626}
14627
14628/* Object.defineProperty() equivalent C binding. */
14629DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags) {
14630 duk_hthread *thr = (duk_hthread *) ctx;
14631 duk_idx_t idx_base;
14632 duk_hobject *obj;
14633 duk_hstring *key;
14634 duk_idx_t idx_value;
14635 duk_hobject *get;
14636 duk_hobject *set;
14637 duk_uint_t is_data_desc;
14638 duk_uint_t is_acc_desc;
14639
14641
14642 obj = duk_require_hobject(ctx, obj_index);
14643
14644 is_data_desc = flags & (DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);
14645 is_acc_desc = flags & (DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);
14646 if (is_data_desc && is_acc_desc) {
14647 /* "Have" flags must not be conflicting so that they would
14648 * apply to both a plain property and an accessor at the same
14649 * time.
14650 */
14651 goto fail_invalid_desc;
14652 }
14653
14654 idx_base = duk_get_top_index(ctx);
14655 if (flags & DUK_DEFPROP_HAVE_SETTER) {
14659 set = duk_get_hobject_or_lfunc_coerce(ctx, idx_base);
14660 if (set != NULL && !DUK_HOBJECT_IS_CALLABLE(set)) {
14661 goto fail_not_callable;
14662 }
14663 idx_base--;
14664 } else {
14665 set = NULL;
14666 }
14667 if (flags & DUK_DEFPROP_HAVE_GETTER) {
14671 get = duk_get_hobject_or_lfunc_coerce(ctx, idx_base);
14672 if (get != NULL && !DUK_HOBJECT_IS_CALLABLE(get)) {
14673 goto fail_not_callable;
14674 }
14675 idx_base--;
14676 } else {
14677 get = NULL;
14678 }
14679 if (flags & DUK_DEFPROP_HAVE_VALUE) {
14680 idx_value = idx_base;
14681 idx_base--;
14682 } else {
14683 idx_value = (duk_idx_t) -1;
14684 }
14685 key = duk_require_hstring(ctx, idx_base);
14686
14687 duk_require_valid_index(ctx, idx_base);
14688
14690 flags /*defprop_flags*/,
14691 obj,
14692 key,
14693 idx_value,
14694 get,
14695 set);
DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags)
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_hobject_define_accessor_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_hobject *getter, duk_hobject *setter, duk_small_uint_t propflags)
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_IS_CALLABLE(h)
#define DUK_BIDX_TYPE_ERROR_THROWER
DUK_EXTERNAL duk_idx_t duk_get_top_index(duk_context *ctx)
#define DUK_HTHREAD_GET_STRING(thr, idx)
DUK_EXTERNAL void duk_require_valid_index(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_hobject_define_property_helper(duk_context *ctx, duk_uint_t defprop_flags, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_value, duk_hobject *get, duk_hobject *set)
DUK_INTERNAL_DECL duk_hstring * duk_require_hstring(duk_context *ctx, duk_idx_t index)
#define DUK_DEFPROP_HAVE_GETTER
#define DUK_DEFPROP_HAVE_VALUE
#define DUK_DEFPROP_HAVE_WRITABLE
#define DUK_DEFPROP_HAVE_SETTER
#define duk_require_type_mask(ctx, index, mask)
duk_hobject * builtins[DUK_NUM_BUILTINS]

◆ duk_del_prop()

DUK_EXTERNAL_DECL duk_bool_t duk_del_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14417 of file duktape-1.5.2/src-noline/duktape.c.

14421 {
14422 duk_hthread *thr = (duk_hthread *) ctx;
14423
14425 DUK_ASSERT_DISABLE(stridx >= 0);
14427 DUK_UNREF(thr);
14428
14429 obj_idx = duk_require_normalize_index(ctx, obj_idx);
14430 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
14431 return duk__put_prop_shared(ctx, obj_idx, -1);
14432}
14433
14435 duk_hthread *thr = (duk_hthread *) ctx;
14436 duk_tval *tv_obj;
14437 duk_tval *tv_key;
14438 duk_small_int_t throw_flag;
14439 duk_bool_t rc;
#define DUK_ASSERT_DISABLE(x)
DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index)
DUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h)
DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key)

◆ duk_del_prop_index()

DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14450 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_del_prop_string()

DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14441 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_del_var()

Definition at line 19936 of file duktape-1.5.2/src-noline/duktape.c.

19936 {
19937 duk_js_putvar_activation(thr, act, h_varname, tv_val, throw_flag); /* -> [ ... varname val this ] */
19938 } else {
19939 /* Outside any activation -> put to global. */
19940 DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL_ENV] != NULL);
19941 duk_js_putvar_envrec(thr, thr->builtins[DUK_BIDX_GLOBAL_ENV], h_varname, tv_val, throw_flag);
DUK_INTERNAL_DECL void duk_js_putvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_tval *val, duk_bool_t strict)
DUK_INTERNAL_DECL void duk_js_putvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_bool_t strict)

◆ duk_destroy_heap()

DUK_EXTERNAL_DECL void duk_destroy_heap ( duk_context * ctx)

Definition at line 14033 of file duktape-1.5.2/src-noline/duktape.c.

14041 {
14042 return NULL;
14043 }
14044 ctx = (duk_context *) heap->heap_thread;

◆ duk_dump_function()

DUK_EXTERNAL_DECL void duk_dump_function ( duk_context * ctx)

Definition at line 12234 of file duktape-1.5.2/src-noline/duktape.c.

12243 : %!iT", duk_get_tval(ctx, -1)));
12244 DUK_ASSERT_TOP(ctx, idx_base + 1);
12245 return p;
12246
12247 format_error:
12248 return NULL;
12249}
12250
12251DUK_EXTERNAL void duk_dump_function(duk_context *ctx) {
12252 duk_hthread *thr;
12253 duk_hcompiledfunction *func;
12254 duk_bufwriter_ctx bw_ctx_alloc;
12255 duk_bufwriter_ctx *bw_ctx = &bw_ctx_alloc;
12256 duk_uint8_t *p;
12257
12258 DUK_ASSERT(ctx != NULL);
12259 thr = (duk_hthread *) ctx;
12260
12261 /* Bound functions don't have all properties so we'd either need to
12262 * lookup the non-bound target function or reject bound functions.
12263 * For now, bound functions are rejected.
12264 */
12265 func = duk_require_hcompiledfunction(ctx, -1);
12266 DUK_ASSERT(func != NULL);

◆ duk_dup()

DUK_EXTERNAL_DECL void duk_dup ( duk_context * ctx,
duk_idx_t from_index )

Definition at line 15702 of file duktape-1.5.2/src-noline/duktape.c.

15713 {
15715
15716 duk_swap(ctx, index, -1);
15717}
DUK_EXTERNAL void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2)

◆ duk_dup_top()

DUK_EXTERNAL_DECL void duk_dup_top ( duk_context * ctx)

Definition at line 15719 of file duktape-1.5.2/src-noline/duktape.c.

15719 {
15720 duk_hthread *thr;
15721 duk_tval *tv_from;
15722 duk_tval *tv_to;
15723
15725 thr = (duk_hthread *) ctx;
15727
15728 tv_from = duk_require_tval(ctx, from_index);
15729 tv_to = thr->valstack_top++;
15730 DUK_ASSERT(tv_from != NULL);
15731 DUK_ASSERT(tv_to != NULL);
15732 DUK_TVAL_SET_TVAL(tv_to, tv_from);
15733 DUK_TVAL_INCREF(thr, tv_to); /* no side effects */
15734}
15735
15737 duk_hthread *thr;
15738 duk_tval *tv_from;
#define DUK_TVAL_SET_TVAL(v, x)
#define DUK_TVAL_INCREF(thr, tv)
DUK_EXTERNAL void duk_dup_top(duk_context *ctx)
DUK_INTERNAL_DECL duk_tval * duk_require_tval(duk_context *ctx, duk_idx_t index)

◆ duk_enum()

DUK_EXTERNAL_DECL void duk_enum ( duk_context * ctx,
duk_idx_t obj_index,
duk_uint_t enum_flags )

Definition at line 14719 of file duktape-1.5.2/src-noline/duktape.c.

14721 {
14722 duk_hthread *thr = (duk_hthread *) ctx;
14723 duk_hobject *obj;
14724

◆ duk_equals()

DUK_EXTERNAL_DECL duk_bool_t duk_equals ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19282 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_eval_raw()

DUK_EXTERNAL_DECL duk_int_t duk_eval_raw ( duk_context * ctx,
const char * src_buffer,
duk_size_t src_length,
duk_uint_t flags )

Definition at line 13532 of file duktape-1.5.2/src-noline/duktape.c.

13542 {
13543 duk_size_t src_length; /* should be first on 64-bit platforms */
13544 const duk_uint8_t *src_buffer;
13545 duk_uint_t flags;
13546};
13547
13548/* Eval is just a wrapper now. */
13549DUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) {
13550 duk_uint_t comp_flags;
13551 duk_int_t rc;
13552
13554
13555 /* Note: strictness is *not* inherited from the current Duktape/C.
13556 * This would be confusing because the current strictness state
13557 * depends on whether we're running inside a Duktape/C activation
13558 * (= strict mode) or outside of any activation (= non-strict mode).
13559 * See tests/api/test-eval-strictness.c for more discussion.
13560 */
13561
13562 /* [ ... source? filename? ] (depends on flags) */
13563
13564 comp_flags = flags;
13565 comp_flags |= DUK_COMPILE_EVAL;
13566 rc = duk_compile_raw(ctx, src_buffer, src_length, comp_flags); /* may be safe, or non-safe depending on flags */
13567
13568 /* [ ... closure/error ] */
13569
13570 if (rc != DUK_EXEC_SUCCESS) {
13571 rc = DUK_EXEC_ERROR;
13572 goto got_rc;
13573 }
13574
13575 duk_push_global_object(ctx); /* explicit 'this' binding, see GH-164 */
DUK_EXTERNAL void duk_push_global_object(duk_context *ctx)
DUK_EXTERNAL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
DUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)

◆ duk_free()

DUK_EXTERNAL_DECL void duk_free ( duk_context * ctx,
void * ptr )

Definition at line 14199 of file duktape-1.5.2/src-noline/duktape.c.

14200 {
14201 duk_hthread *thr = (duk_hthread *) ctx;
14202
14204
14205 return DUK_REALLOC_RAW(thr->heap, ptr, size);
#define DUK_REALLOC_RAW(heap, ptr, newsize)

◆ duk_free_raw()

DUK_EXTERNAL_DECL void duk_free_raw ( duk_context * ctx,
void * ptr )

Definition at line 14175 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_gc()

DUK_EXTERNAL_DECL void duk_gc ( duk_context * ctx,
duk_uint_t flags )

Definition at line 14241 of file duktape-1.5.2/src-noline/duktape.c.

14242 {
14243 duk_hthread *thr = (duk_hthread *) ctx;
14244 duk_heap *heap;
14245
14247 DUK_ASSERT(out_funcs != NULL);
14248 DUK_ASSERT(thr != NULL);
14249 DUK_ASSERT(thr->heap != NULL);
14250
14251 heap = thr->heap;
14252 out_funcs->alloc_func = heap->alloc_func;
14253 out_funcs->realloc_func = heap->realloc_func;
14254 out_funcs->free_func = heap->free_func;
14255 out_funcs->udata = heap->heap_udata;
14256}
14257
14258DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags) {
14259#ifdef DUK_USE_MARK_AND_SWEEP
14260 duk_hthread *thr = (duk_hthread *) ctx;
14261 duk_heap *heap;
14262
14263 DUK_UNREF(flags);
DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags)
duk_realloc_function realloc_func
duk_alloc_function alloc_func

◆ duk_get_boolean()

DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 15965 of file duktape-1.5.2/src-noline/duktape.c.

15968 {
15969 duk_hthread *thr = (duk_hthread *) ctx;
15970 duk_tval *tv;
15971
15973
15974 tv = duk_get_tval(ctx, index);
15975 if (tv && DUK_TVAL_IS_NULL(tv)) {
15976 return;
15977 }
#define DUK_TVAL_IS_NULL(tv)
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr, index, expectname, lowmemstr)
DUK_INTERNAL_DECL duk_tval * duk_get_tval(duk_context *ctx, duk_idx_t index)

◆ duk_get_buffer()

DUK_EXTERNAL_DECL void * duk_get_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16197 of file duktape-1.5.2/src-noline/duktape.c.

16199 {

◆ duk_get_buffer_data()

DUK_EXTERNAL_DECL void * duk_get_buffer_data ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16259 of file duktape-1.5.2/src-noline/duktape.c.

16260 {
16261 *out_size = (duk_size_t) h_bufobj->length;

◆ duk_get_c_function()

DUK_EXTERNAL_DECL duk_c_function duk_get_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16378 of file duktape-1.5.2/src-noline/duktape.c.

16378 {
16380 if (h != NULL && !DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
16381 h = NULL;
16382 }
16383 return (duk_hnativefunction *) h;
16384}
16385
16387 duk_hthread *thr = (duk_hthread *) ctx;
16389 if (!(h != NULL && DUK_HOBJECT_IS_NATIVEFUNCTION(h))) {
16391 }
16392 return (duk_hnativefunction *) h;
16393}
16394
16396 duk_tval *tv;
16397 duk_hobject *h;
16399
16401
16402 tv = duk_get_tval(ctx, index);
#define DUK_STR_NOT_NATIVEFUNCTION
#define DUK_HOBJECT_IS_NATIVEFUNCTION(h)
DUK_EXTERNAL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hnativefunction * duk_require_hnativefunction(duk_context *ctx, duk_idx_t index)
DUK_LOCAL_DECL duk_heaphdr * duk__get_tagged_heaphdr_raw(duk_context *ctx, duk_idx_t index, duk_uint_t tag)
duk_ret_t(* duk_c_function)(duk_context *ctx)

◆ duk_get_context()

DUK_EXTERNAL_DECL duk_context * duk_get_context ( duk_context * ctx,
duk_idx_t index )

Definition at line 16423 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_current_magic()

DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic ( duk_context * ctx)

Definition at line 12817 of file duktape-1.5.2/src-noline/duktape.c.

12823 {
12824 /* Strict by default. */
12825 return 1;
12826 }
12827 return ((act->flags & DUK_ACT_FLAG_STRICT) != 0 ? 1 : 0);
12828}
12829
12830/*
12831 * Duktape/C function magic
12832 */
12833
12835 duk_hthread *thr = (duk_hthread *) ctx;
12836 duk_activation *act;
12837 duk_hobject *func;
12838
12840 DUK_ASSERT(thr != NULL);
12842
DUK_EXTERNAL duk_int_t duk_get_current_magic(duk_context *ctx)
DUK_INTERNAL_DECL duk_activation * duk_hthread_get_current_activation(duk_hthread *thr)

◆ duk_get_error_code()

DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code ( duk_context * ctx,
duk_idx_t index )

Definition at line 17789 of file duktape-1.5.2/src-noline/duktape.c.

17792 {
17793 duk_tval *tv;
17794
17796
17797 tv = duk_get_tval(ctx, index);
17798 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17800 DUK_ASSERT(h != NULL);
17801 return (DUK_HBUFFER_HAS_DYNAMIC(h) && DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);
17802 }
17803 return 0;
17804}
17805
17807 duk_hthread *thr = (duk_hthread *) ctx;
17808 duk_hobject *h;
17809 duk_uint_t sanity;
17810
17812
17813 h = duk_get_hobject(ctx, index);
17814
17816 do {
17817 if (!h) {
17818 return DUK_ERR_NONE;
17819 }
17820 if (h == thr->builtins[DUK_BIDX_EVAL_ERROR_PROTOTYPE]) {
17821 return DUK_ERR_EVAL_ERROR;
17822 }
17824 return DUK_ERR_RANGE_ERROR;
17825 }
17828 }
#define DUK_BIDX_EVAL_ERROR_PROTOTYPE
DUK_EXTERNAL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_IS_BUFFER(tv)
#define DUK_TVAL_GET_BUFFER(tv)
#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE
#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE
#define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject(duk_context *ctx, duk_idx_t index)
#define DUK_BIDX_RANGE_ERROR_PROTOTYPE
#define DUK_HBUFFER_HAS_EXTERNAL(x)
#define DUK_HBUFFER_HAS_DYNAMIC(x)
#define DUK_ERR_RANGE_ERROR
#define DUK_ERR_REFERENCE_ERROR

◆ duk_get_finalizer()

DUK_EXTERNAL_DECL void duk_get_finalizer ( duk_context * ctx,
duk_idx_t index )

Definition at line 14863 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_global_string()

DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string ( duk_context * ctx,
const char * key )

Definition at line 14773 of file duktape-1.5.2/src-noline/duktape.c.

14777 {
14778 while (ent->key != NULL) {
14779 duk_push_number(ctx, ent->value);
14780 duk_put_prop_string(ctx, obj_index, ent->key);
14781 ent++;
14782 }
14783 }
14784}
14785
14786/*
DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key)
DUK_EXTERNAL void duk_push_number(duk_context *ctx, duk_double_t val)

◆ duk_get_heapptr()

DUK_EXTERNAL_DECL void * duk_get_heapptr ( duk_context * ctx,
duk_idx_t index )

Definition at line 16435 of file duktape-1.5.2/src-noline/duktape.c.

16435 {
16437 }
16438}
16439
16442
16443 return (duk_context *) duk_get_hthread(ctx, index);
16444}
16445
16448
16449 return (duk_context *) duk_require_hthread(ctx, index);
DUK_INTERNAL_DECL duk_hthread * duk_require_hthread(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hthread * duk_get_hthread(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_context * duk_get_context(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_context * duk_require_context(duk_context *ctx, duk_idx_t index)

◆ duk_get_int()

◆ duk_get_length()

DUK_EXTERNAL_DECL duk_size_t duk_get_length ( duk_context * ctx,
duk_idx_t index )

Definition at line 16575 of file duktape-1.5.2/src-noline/duktape.c.

16582 {
16583 duk_hstring *h_class;
16585 DUK_UNREF(h_class);
16586
16588 }
16589 return h;
16590}
16591
16593 duk_tval *tv;
16594
16596
16597 tv = duk_get_tval(ctx, index);
16598 if (!tv) {
16599 return 0;
16600 }
16601
16602 switch (DUK_TVAL_GET_TAG(tv)) {
16603 case DUK_TAG_UNDEFINED:
16604 case DUK_TAG_NULL:
16605 case DUK_TAG_BOOLEAN:
16606 case DUK_TAG_POINTER:
16607 return 0;
16608 case DUK_TAG_STRING: {
16610 DUK_ASSERT(h != NULL);
16612 }
16613 case DUK_TAG_OBJECT: {
16615 DUK_ASSERT(h != NULL);
16616 return (duk_size_t) duk_hobject_get_length((duk_hthread *) ctx, h);
16617 }
16618 case DUK_TAG_BUFFER: {
16620 DUK_ASSERT(h != NULL);
16621 return (duk_size_t) DUK_HBUFFER_GET_SIZE(h);
16622 }
#define DUK_HSTRING_GET_DATA(x)
#define DUK_TVAL_GET_OBJECT(tv)
#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(n)
DUK_EXTERNAL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index)
#define DUK_HSTRING_GET_CHARLEN(x)
#define DUK_TVAL_GET_TAG(tv)
#define DUK_TVAL_GET_STRING(tv)
DUK_INTERNAL_DECL duk_uint32_t duk_hobject_get_length(duk_hthread *thr, duk_hobject *obj)
#define DUK_STR_UNEXPECTED_TYPE
#define DUK_HBUFFER_GET_SIZE(x)

◆ duk_get_lstring()

DUK_EXTERNAL_DECL const char * duk_get_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16064 of file duktape-1.5.2/src-noline/duktape.c.

16069 {
16070 /* Custom coercion for API */
16072 return (duk_int_t) duk__api_coerce_d2i(ctx, index, 1 /*require*/);
16073}
16074
16076 /* Custom coercion for API */
16078 return (duk_uint_t) duk__api_coerce_d2ui(ctx, index, 1 /*require*/);
16079}
16080
16082 const char *ret;
16083 duk_tval *tv;
16084
16086
16087 /* default: NULL, length 0 */
16088 ret = NULL;
16089 if (out_len) {
16090 *out_len = 0;
DUK_EXTERNAL const char * duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_LOCAL duk_int_t duk__api_coerce_d2i(duk_context *ctx, duk_idx_t index, duk_bool_t require)
DUK_EXTERNAL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_uint_t duk__api_coerce_d2ui(duk_context *ctx, duk_idx_t index, duk_bool_t require)

◆ duk_get_magic()

DUK_EXTERNAL_DECL duk_int_t duk_get_magic ( duk_context * ctx,
duk_idx_t index )

Definition at line 12845 of file duktape-1.5.2/src-noline/duktape.c.

12846 {
12847 duk_tval *tv = &act->tv_func;
12848 duk_small_uint_t lf_flags;
12849 lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv);
12850 return (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);
12851 }
12852 DUK_ASSERT(func != NULL);
12853
12856 return (duk_int_t) nf->magic;
12857 }
12858 }
12859 return 0;
12860}
12861
12863 duk_hthread *thr = (duk_hthread *) ctx;
12864 duk_tval *tv;
12865 duk_hobject *h;
12866
12868
12869 tv = duk_require_tval(ctx, index);
#define DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags)
#define DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv)
DUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index)

◆ duk_get_memory_functions()

DUK_EXTERNAL_DECL void duk_get_memory_functions ( duk_context * ctx,
duk_memory_functions * out_funcs )

Definition at line 14225 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_number()

DUK_EXTERNAL_DECL duk_double_t duk_get_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 15996 of file duktape-1.5.2/src-noline/duktape.c.

15997 {
15998 duk_hthread *thr = (duk_hthread *) ctx;
15999 duk_tval *tv;
16000
16002
16003 tv = duk_get_tval(ctx, index);
16004 if (tv && DUK_TVAL_IS_BOOLEAN(tv)) {
16006 DUK_ASSERT(ret == 0 || ret == 1);
16007 return ret;
16008 }
16010 return 0; /* not reachable */
16011}
16012
16014 duk_double_union ret;
16015 duk_tval *tv;
DUK_EXTERNAL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_GET_BOOLEAN(tv)
#define DUK_TVAL_IS_BOOLEAN(tv)

◆ duk_get_pointer()

DUK_EXTERNAL_DECL void * duk_get_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 16121 of file duktape-1.5.2/src-noline/duktape.c.

16126 {
16128
16129 return duk_get_lstring(ctx, index, NULL);
16130}
16131
DUK_EXTERNAL const char * duk_require_string(duk_context *ctx, duk_idx_t index)

◆ duk_get_prop()

DUK_EXTERNAL_DECL duk_bool_t duk_get_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14278 of file duktape-1.5.2/src-noline/duktape.c.

14295 {
14296 duk_hthread *thr = (duk_hthread *) ctx;
14297 duk_tval *tv_obj;
14298 duk_tval *tv_key;
14299 duk_bool_t rc;

◆ duk_get_prop_index()

DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14310 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_prop_string()

DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14301 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_prototype()

DUK_EXTERNAL_DECL void duk_get_prototype ( duk_context * ctx,
duk_idx_t index )

Definition at line 14808 of file duktape-1.5.2/src-noline/duktape.c.

14825 {
14826 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_get_string()

DUK_EXTERNAL_DECL const char * duk_get_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 16109 of file duktape-1.5.2/src-noline/duktape.c.

16109 {
16110 duk_hthread *thr = (duk_hthread *) ctx;
16111 const char *ret;
16112

◆ duk_get_top()

DUK_EXTERNAL_DECL duk_idx_t duk_get_top ( duk_context * ctx)

Definition at line 15204 of file duktape-1.5.2/src-noline/duktape.c.

15205 {
15206 duk_hthread *thr = (duk_hthread *) ctx;
15207
15210

◆ duk_get_top_index()

DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index ( duk_context * ctx)

Definition at line 15307 of file duktape-1.5.2/src-noline/duktape.c.

15315 {
15316 tv--;
15318 } while (tv != tv_end);
15319 thr->valstack_top = tv_end;
15320#endif /* DUK_USE_REFERENCE_COUNTING */
15321 }
15322}
#define DUK_TVAL_SET_UNDEFINED(tv)

◆ duk_get_type()

DUK_EXTERNAL_DECL duk_int_t duk_get_type ( duk_context * ctx,
duk_idx_t index )

Definition at line 17478 of file duktape-1.5.2/src-noline/duktape.c.

17483 {
17484 duk_hobject *obj;
17485
17487
17488 obj = duk_get_hobject(ctx, index);
17489 if (obj) {
17490 return (DUK_HEAPHDR_CHECK_FLAG_BITS((duk_heaphdr *) obj, flag_mask) ? 1 : 0);
17491 }
17492 return 0;
17493}
17494
17496 duk_tval *tv;
17497
17499
17500 tv = duk_get_tval(ctx, index);
17501 if (!tv) {
17502 return DUK_TYPE_NONE;
17503 }
17504 switch (DUK_TVAL_GET_TAG(tv)) {
17505 case DUK_TAG_UNDEFINED:
17506 return DUK_TYPE_UNDEFINED;
17507 case DUK_TAG_NULL:
17508 return DUK_TYPE_NULL;
17509 case DUK_TAG_BOOLEAN:
17510 return DUK_TYPE_BOOLEAN;
17511 case DUK_TAG_STRING:
17512 return DUK_TYPE_STRING;
17513 case DUK_TAG_OBJECT:
17514 return DUK_TYPE_OBJECT;
#define DUK_HEAPHDR_CHECK_FLAG_BITS(h, bits)
DUK_EXTERNAL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index)

◆ duk_get_type_mask()

DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask ( duk_context * ctx,
duk_idx_t index )

Definition at line 17547 of file duktape-1.5.2/src-noline/duktape.c.

17547 {
17548 duk_int_t type_tag;
17549
17550 type_tag = duk_get_type(ctx, index);
17551 DUK_ASSERT(type_tag >= DUK_TYPE_MIN && type_tag <= DUK_TYPE_MAX);
17552 DUK_ASSERT(DUK_TYPE_MIN == 0 && sizeof(duk__type_names) / sizeof(const char *) == DUK_TYPE_MAX + 1);
17553
17554 return duk__type_names[type_tag];
17555}
17556#endif
17557
17560
17561 return (duk_get_type(ctx, index) == type) ? 1 : 0;
17562}
17563
17565 duk_tval *tv;
17566
17568
17569 tv = duk_get_tval(ctx, index);
17570 if (!tv) {
17571 return DUK_TYPE_MASK_NONE;
17572 }
17573 switch (DUK_TVAL_GET_TAG(tv)) {
17574 case DUK_TAG_UNDEFINED:
17576 case DUK_TAG_NULL:
17577 return DUK_TYPE_MASK_NULL;
17578 case DUK_TAG_BOOLEAN:
17579 return DUK_TYPE_MASK_BOOLEAN;
17580 case DUK_TAG_STRING:
17581 return DUK_TYPE_MASK_STRING;
17582 case DUK_TAG_OBJECT:
17583 return DUK_TYPE_MASK_OBJECT;
DUK_EXTERNAL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type)
DUK_EXTERNAL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index)

◆ duk_get_uint()

DUK_EXTERNAL_DECL duk_uint_t duk_get_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16046 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_get_var()

DUK_EXTERNAL_DECL void duk_get_var ( duk_context * ctx)

Definition at line 19869 of file duktape-1.5.2/src-noline/duktape.c.

19872 {
19873 return 0;
19874 }
19875
19876 DUK_ASSERT(char_offset <= DUK_UINT_MAX); /* guaranteed by string limits */
19877 cp = duk_hstring_char_code_at_raw(thr, h, (duk_uint_t) char_offset);
19878 return (duk_codepoint_t) cp;
19879}
19880/*
19881 * Variable access
19882 */
19883
19884/* include removed: duk_internal.h */
19885
19887 duk_hthread *thr = (duk_hthread *) ctx;
19888 duk_activation *act;
19889 duk_hstring *h_varname;
19890 duk_small_int_t throw_flag = 1; /* always throw ReferenceError for unresolvable */
19891
19893
19894 h_varname = duk_require_hstring(ctx, -1); /* XXX: tostring? */
19895 DUK_ASSERT(h_varname != NULL);
19896
19898 if (act) {
19899 (void) duk_js_getvar_activation(thr, act, h_varname, throw_flag); /* -> [ ... varname val this ] */
19900 } else {
DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, duk_hstring *h, duk_uint_t pos)
DUK_EXTERNAL void duk_get_var(duk_context *ctx)
DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_bool_t throw_flag)

◆ duk_has_prop()

DUK_EXTERNAL_DECL duk_bool_t duk_has_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14471 of file duktape-1.5.2/src-noline/duktape.c.

14475 {
14476 duk_hthread *thr = (duk_hthread *) ctx;
14477
14479 DUK_ASSERT_DISABLE(stridx >= 0);
14481 DUK_UNREF(thr);
14482
14483 obj_index = duk_require_normalize_index(ctx, obj_index);
14484 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
14485 return duk_del_prop(ctx, obj_index);
14486}
14487
14489 duk_hthread *thr = (duk_hthread *) ctx;
14490 duk_tval *tv_obj;
14491 duk_tval *tv_key;
DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index)

◆ duk_has_prop_index()

DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14502 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_has_prop_string()

DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14493 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_has_var()

Definition at line 19943 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_hex_decode()

DUK_EXTERNAL_DECL void duk_hex_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13389 of file duktape-1.5.2/src-noline/duktape.c.

13406 {
13407 duk_hthread *thr = (duk_hthread *) ctx;
13408 const duk_uint8_t *inp;
13409 duk_size_t len;
13410 duk_size_t i;
13411 duk_int_t t;
13412 duk_uint8_t *buf;
13413#if defined(DUK_USE_HEX_FASTPATH)
13414 duk_int_t chk;
13415 duk_uint8_t *p;
13416 duk_size_t len_safe;
13417#endif
13418
13420
13422 inp = duk__prep_codec_arg(ctx, index, &len);
13423 DUK_ASSERT(inp != NULL || len == 0);
13424
13425 if (len & 0x01) {
13426 goto type_error;
13427 }
13428
13429 /* Fixed buffer, no zeroing because we'll fill all the data. */
13430 buf = (duk_uint8_t *) duk_push_buffer_raw(ctx, len / 2, DUK_BUF_FLAG_NOZERO /*flags*/);
13431 DUK_ASSERT(buf != NULL);
13432
13433#if defined(DUK_USE_HEX_FASTPATH)
13434 p = buf;
13435 len_safe = len & ~0x07U;
13436 for (i = 0; i < len_safe; i += 8) {
13437 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i]]) |
13438 ((duk_int_t) duk_hex_dectab[inp[i + 1]]);
13439 chk = t;
13440 p[0] = (duk_uint8_t) t;
13441 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 2]]) |
13442 ((duk_int_t) duk_hex_dectab[inp[i + 3]]);
13443 chk |= t;
13444 p[1] = (duk_uint8_t) t;
13445 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 4]]) |
13446 ((duk_int_t) duk_hex_dectab[inp[i + 5]]);
13447 chk |= t;
13448 p[2] = (duk_uint8_t) t;
13449 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 6]]) |
13450 ((duk_int_t) duk_hex_dectab[inp[i + 7]]);
13451 chk |= t;
13452 p[3] = (duk_uint8_t) t;
13453 p += 4;
13454
13455 /* Check if any lookup above had a negative result. */
13456 if (DUK_UNLIKELY(chk < 0)) {
13457 goto type_error;
13458 }
13459 }
13460 for (; i < len; i += 2) {
13461 t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) |
13462 ((duk_int_t) duk_hex_dectab[inp[i + 1]]);
13463 if (DUK_UNLIKELY(t < 0)) {
13464 goto type_error;
13465 }
13466 *p++ = (duk_uint8_t) t;
13467 }
13468#else /* DUK_USE_HEX_FASTPATH */
13469 for (i = 0; i < len; i += 2) {
13470 /* For invalid characters the value -1 gets extended to
13471 * at least 16 bits. If either nybble is invalid, the
DUK_EXTERNAL void * duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags)
DUK_INTERNAL const duk_int8_t duk_hex_dectab[256]
DUK_INTERNAL const duk_int16_t duk_hex_dectab_shift4[256]
#define DUK_BUF_FLAG_NOZERO

◆ duk_hex_encode()

DUK_EXTERNAL_DECL const char * duk_hex_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13333 of file duktape-1.5.2/src-noline/duktape.c.

13337 {
13338 goto type_error;
13339 }
13340
13341 /* XXX: convert to fixed buffer? */
13342 (void) duk_resize_buffer(ctx, -1, (duk_size_t) (dst_final - dst));
13343 duk_replace(ctx, index);
13344 return;
13345
13346 type_error:
13348}
13349
13351 const duk_uint8_t *inp;
13352 duk_size_t len;
13353 duk_size_t i;
13354 duk_uint8_t *buf;
13355 const char *ret;
13356#if defined(DUK_USE_HEX_FASTPATH)
13357 duk_size_t len_safe;
13358 duk_uint16_t *p16;
13359#endif
13360
13362
13364 inp = duk__prep_codec_arg(ctx, index, &len);
13365 DUK_ASSERT(inp != NULL || len == 0);
13366
13367 /* Fixed buffer, no zeroing because we'll fill all the data. */
13368 buf = (duk_uint8_t *) duk_push_buffer_raw(ctx, len * 2, DUK_BUF_FLAG_NOZERO /*flags*/);
13369 DUK_ASSERT(buf != NULL);
13370
13371#if defined(DUK_USE_HEX_FASTPATH)
13372 DUK_ASSERT((((duk_size_t) buf) & 0x01U) == 0); /* pointer is aligned, guaranteed for fixed buffer */
13373 p16 = (duk_uint16_t *) (void *) buf;
13374 len_safe = len & ~0x03U;
13375 for (i = 0; i < len_safe; i += 4) {
13376 p16[0] = duk_hex_enctab[inp[i]];
13377 p16[1] = duk_hex_enctab[inp[i + 1]];
13378 p16[2] = duk_hex_enctab[inp[i + 2]];
13379 p16[3] = duk_hex_enctab[inp[i + 3]];
13380 p16 += 4;
13381 }
13382 for (; i < len; i++) {
13383 *p16++ = duk_hex_enctab[inp[i]];
13384 }
13385#else /* DUK_USE_HEX_FASTPATH */
13386 for (i = 0; i < len; i++) {
DUK_EXTERNAL const char * duk_hex_encode(duk_context *ctx, duk_idx_t index)
#define DUK_STR_DECODE_FAILED
DUK_EXTERNAL void * duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size)
DUK_INTERNAL const duk_uint16_t duk_hex_enctab[256]

◆ duk_insert()

DUK_EXTERNAL_DECL void duk_insert ( duk_context * ctx,
duk_idx_t to_index )

Definition at line 15740 of file duktape-1.5.2/src-noline/duktape.c.

15745 {
15746 DUK_ERROR_API_INDEX(thr, -1);
15747 return; /* unreachable */
15748 }
15749 tv_from = thr->valstack_top - 1;
15750 tv_to = thr->valstack_top++;
15751 DUK_ASSERT(tv_from != NULL);
15752 DUK_ASSERT(tv_to != NULL);
15753 DUK_TVAL_SET_TVAL(tv_to, tv_from);
15754 DUK_TVAL_INCREF(thr, tv_to); /* no side effects */
15755}
15756
15757DUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_index) {
15758 duk_tval *p;
15759 duk_tval *q;
15760 duk_tval tv_tmp;
15761 duk_size_t nbytes;
15762
15764
15765 p = duk_require_tval(ctx, to_index);
15766 DUK_ASSERT(p != NULL);
15767 q = duk_require_tval(ctx, -1);
15768 DUK_ASSERT(q != NULL);
15769
15770 DUK_ASSERT(q >= p);
15771
15772 /* nbytes
15773 * <--------->
15774 * [ ... | p | x | x | q ]
15775 * => [ ... | q | p | x | x ]
15776 */
15777
15778 nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */
#define DUK_ERROR_API_INDEX(thr, index)
DUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_index)

◆ duk_instanceof()

DUK_EXTERNAL_DECL duk_bool_t duk_instanceof ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19319 of file duktape-1.5.2/src-noline/duktape.c.

19324 {
19325 return 0;
19326 }
19327
19328 /* No coercions or other side effects, so safe */
19329 return duk_js_strict_equals(tv1, tv2);
19330}
19331
19332/*
19333 * instanceof
19334 */
19335
DUK_EXTERNAL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
#define duk_js_strict_equals(tv_x, tv_y)

◆ duk_is_array()

DUK_EXTERNAL_DECL duk_bool_t duk_is_array ( duk_context * ctx,
duk_idx_t index )

Definition at line 17691 of file duktape-1.5.2/src-noline/duktape.c.

17693 {
17695 return duk__tag_check(ctx, index, DUK_TAG_BUFFER);
17696}
17697
17700 return duk__tag_check(ctx, index, DUK_TAG_POINTER);
17701}
DUK_EXTERNAL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_bool_t duk__tag_check(duk_context *ctx, duk_idx_t index, duk_small_uint_t tag)

◆ duk_is_boolean()

DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 17624 of file duktape-1.5.2/src-noline/duktape.c.

17627 {

◆ duk_is_bound_function()

DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17733 of file duktape-1.5.2/src-noline/duktape.c.

17736 {
DUK_LOCAL duk_bool_t duk__obj_flag_any_default_false(duk_context *ctx, duk_idx_t index, duk_uint_t flag_mask)

◆ duk_is_buffer()

DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17676 of file duktape-1.5.2/src-noline/duktape.c.

17677 {
17678 return 0;
17679 }

◆ duk_is_c_function()

DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17719 of file duktape-1.5.2/src-noline/duktape.c.

17720 {
17721 duk_tval *tv;
17722
17724

◆ duk_is_constructor_call()

DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call ( duk_context * ctx)

Definition at line 12775 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_is_dynamic_buffer()

DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17761 of file duktape-1.5.2/src-noline/duktape.c.

17764 {
17765 duk_tval *tv;
17766
17768
17769 tv = duk_get_tval(ctx, index);
17770 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17772 DUK_ASSERT(h != NULL);
17773 return (DUK_HBUFFER_HAS_DYNAMIC(h) ? 0 : 1);

◆ duk_is_ecmascript_function()

DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17726 of file duktape-1.5.2/src-noline/duktape.c.

17726 {
17727 return 1;
17728 }
17730 index,
#define DUK_HOBJECT_FLAG_COMPILEDFUNCTION

◆ duk_is_external_buffer()

DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17775 of file duktape-1.5.2/src-noline/duktape.c.

17778 {
17779 duk_tval *tv;
17780
17782
17783 tv = duk_get_tval(ctx, index);
17784 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17786 DUK_ASSERT(h != NULL);
17787 return (DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);

◆ duk_is_fixed_buffer()

DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17747 of file duktape-1.5.2/src-noline/duktape.c.

17750 {
17753 index,
17755}
17756
DUK_EXTERNAL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_FLAG_BOUND

◆ duk_is_function()

DUK_EXTERNAL_DECL duk_bool_t duk_is_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17703 of file duktape-1.5.2/src-noline/duktape.c.

17703 {
17706}
17707
17709 duk_hobject *obj;
17710
17712
17713 obj = duk_get_hobject(ctx, index);
17714 if (obj) {
17716 }
17717 return 0;
#define DUK_HOBJECT_CLASS_ARRAY
DUK_EXTERNAL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_GET_CLASS_NUMBER(h)

◆ duk_is_lightfunc()

DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc ( duk_context * ctx,
duk_idx_t index )

Definition at line 17686 of file duktape-1.5.2/src-noline/duktape.c.

17688 {

◆ duk_is_nan()

DUK_EXTERNAL_DECL duk_bool_t duk_is_nan ( duk_context * ctx,
duk_idx_t index )

Definition at line 17648 of file duktape-1.5.2/src-noline/duktape.c.

17659 {
17660 return 0;
17661 }
17662 return DUK_TVAL_IS_NUMBER(tv);
17663}
17664

◆ duk_is_null()

DUK_EXTERNAL_DECL duk_bool_t duk_is_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 17605 of file duktape-1.5.2/src-noline/duktape.c.

17607 {
17608 return 1;

◆ duk_is_null_or_undefined()

DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 17610 of file duktape-1.5.2/src-noline/duktape.c.

17610 {
17613 }
17614 return 0;
17615}
17616
17620}
17621
DUK_EXTERNAL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index)

◆ duk_is_number()

DUK_EXTERNAL_DECL duk_bool_t duk_is_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 17629 of file duktape-1.5.2/src-noline/duktape.c.

17634 {
17635 return 0;
17636 }
17637 tag = DUK_TVAL_GET_TAG(tv);
17638 return (tag == DUK_TAG_UNDEFINED) || (tag == DUK_TAG_NULL);
17639}
17640
17643 return duk__tag_check(ctx, index, DUK_TAG_BOOLEAN);
17644}
17645
DUK_EXTERNAL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index)

◆ duk_is_object()

DUK_EXTERNAL_DECL duk_bool_t duk_is_object ( duk_context * ctx,
duk_idx_t index )

Definition at line 17671 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_is_pointer()

DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17681 of file duktape-1.5.2/src-noline/duktape.c.

17683 {

◆ duk_is_strict_call()

DUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call ( duk_context * ctx)

Definition at line 12788 of file duktape-1.5.2/src-noline/duktape.c.

12792 {
12793 duk_hthread *thr = (duk_hthread *) ctx;
12794 duk_activation *act;
12795
12797 DUK_ASSERT(thr != NULL);
12799
12801 DUK_ASSERT(act != NULL); /* because callstack_top > 0 */
12802 return ((act->flags & DUK_ACT_FLAG_CONSTRUCT) != 0 ? 1 : 0);
12803}
12804
12806 duk_hthread *thr = (duk_hthread *) ctx;
12807 duk_activation *act;
12808
12809 /* For user code this could just return 1 (strict) always
12810 * because all Duktape/C functions are considered strict,
12811 * and strict is also the default when nothing is running.
DUK_EXTERNAL duk_bool_t duk_is_strict_call(duk_context *ctx)
#define DUK_ACT_FLAG_CONSTRUCT

◆ duk_is_string()

DUK_EXTERNAL_DECL duk_bool_t duk_is_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 17666 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_is_thread()

DUK_EXTERNAL_DECL duk_bool_t duk_is_thread ( duk_context * ctx,
duk_idx_t index )

Definition at line 17740 of file duktape-1.5.2/src-noline/duktape.c.

17743 {

◆ duk_is_undefined()

DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 17600 of file duktape-1.5.2/src-noline/duktape.c.

17602 {
17603 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_is_valid_index()

DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15180 of file duktape-1.5.2/src-noline/duktape.c.

15181 {
15183 uindex = (duk_uidx_t) index;
15184 }
15185

◆ duk_join()

DUK_EXTERNAL_DECL void duk_join ( duk_context * ctx,
duk_idx_t count )

Definition at line 19646 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_json_decode()

DUK_EXTERNAL_DECL void duk_json_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13499 of file duktape-1.5.2/src-noline/duktape.c.

13516 {
13517#ifdef DUK_USE_ASSERTIONS

◆ duk_json_encode()

DUK_EXTERNAL_DECL const char * duk_json_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13473 of file duktape-1.5.2/src-noline/duktape.c.

13476 {
13477 goto type_error;
13478 }
13479 buf[i >> 1] = (duk_uint8_t) t;
13480 }
13481#endif /* DUK_USE_HEX_FASTPATH */
13482
13483 duk_replace(ctx, index);
13484 return;
13485
13486 type_error:
13488}
13489
13491#ifdef DUK_USE_ASSERTIONS
13492 duk_idx_t top_at_entry;
13493#endif
13494 const char *ret;
13495
13497#ifdef DUK_USE_ASSERTIONS
DUK_EXTERNAL const char * duk_json_encode(duk_context *ctx, duk_idx_t index)

◆ duk_load_function()

DUK_EXTERNAL_DECL void duk_load_function ( duk_context * ctx)

Definition at line 12268 of file duktape-1.5.2/src-noline/duktape.c.

12280 : %!T", duk_get_tval(ctx, -1)));
12281
12282 duk_remove(ctx, -2); /* [ ... func buf ] -> [ ... buf ] */
12283}
12284
12285DUK_EXTERNAL void duk_load_function(duk_context *ctx) {
12286 duk_hthread *thr;
12287 duk_uint8_t *p_buf, *p, *p_end;
12288 duk_size_t sz;
12289
12290 DUK_ASSERT(ctx != NULL);
12291 thr = (duk_hthread *) ctx;
12292 DUK_UNREF(ctx);
12293
12294 p_buf = (duk_uint8_t *) duk_require_buffer(ctx, -1, &sz);
12295 DUK_ASSERT(p_buf != NULL);
12296
12297 /* The caller is responsible for being sure that bytecode being loaded
12298 * is valid and trusted. Invalid bytecode can cause memory unsafe
12299 * behavior directly during loading or later during bytecode execution
12300 * (instruction validation would be quite complex to implement).
12301 *
12302 * This signature check is the only sanity check for detecting
12303 * accidental invalid inputs. The initial 0xFF byte ensures no
12304 * ordinary string will be accepted by accident.
12305 */
12306 p = p_buf;

◆ duk_log()

DUK_EXTERNAL_DECL void duk_log ( duk_context * ctx,
duk_int_t level,
const char * fmt,
... )

Definition at line 14152 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_log_va()

DUK_EXTERNAL_DECL void duk_log_va ( duk_context * ctx,
duk_int_t level,
const char * fmt,
va_list ap )

Definition at line 14119 of file duktape-1.5.2/src-noline/duktape.c.

14136 {
14137 /* stridx_logfunc[] must be static to allow initializer with old compilers like BCC */
14138 static const duk_uint16_t stridx_logfunc[6] = {
14141 };
14142
14144
14145 if (level < 0) {
14146 level = 0;
14147 } else if (level > (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1) {
14148 level = (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1;
14149 }
14150

◆ duk_map_string()

DUK_EXTERNAL_DECL void duk_map_string ( duk_context * ctx,
duk_idx_t index,
duk_map_char_function callback,
void * udata )

Definition at line 19680 of file duktape-1.5.2/src-noline/duktape.c.

19688 {
19689 if (p >= p_end) {
19690 break;
19691 }
19692 cp = (int) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
19693 callback(udata, cp);
19694 }
19695}
19696
19698 duk_hthread *thr = (duk_hthread *) ctx;
19699 duk_hstring *h_input;
19700 duk_bufwriter_ctx bw_alloc;
19702 const duk_uint8_t *p, *p_start, *p_end;
19703 duk_codepoint_t cp;
19704
19706
19708
19709 h_input = duk_require_hstring(ctx, index);
19710 DUK_ASSERT(h_input != NULL);
19711
19712 bw = &bw_alloc;
19713 DUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input)); /* reasonable output estimate */
19714
19715 p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
19716 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
19717 p = p_start;
19718
19719 for (;;) {
DUK_EXTERNAL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata)
#define DUK_HSTRING_GET_BYTELEN(x)
#define DUK_BW_INIT_PUSHBUF(thr, bw_ctx, sz)
DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end)
duk_codepoint_t(* duk_map_char_function)(void *udata, duk_codepoint_t codepoint)

◆ duk_new()

DUK_EXTERNAL_DECL void duk_new ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12549 of file duktape-1.5.2/src-noline/duktape.c.

12552 {
12553 /* See comments in duk_pcall(). */
12555 return DUK_EXEC_ERROR; /* unreachable */
12556 }
12557
12558 rc = duk_handle_safe_call(thr, /* thread */
12559 func, /* func */
12560 nargs, /* num_stack_args */
12561 nrets); /* num_stack_res */
12562
12563 return rc;
12564}
12565
12566DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) {
12567 /*
12568 * There are two [[Construct]] operations in the specification:
12569 *
12570 * - E5 Section 13.2.2: for Function objects
12571 * - E5 Section 15.3.4.5.2: for "bound" Function objects
12572 *
12573 * The chain of bound functions is resolved in Section 15.3.4.5.2,
12574 * with arguments "piling up" until the [[Construct]] internal
12575 * method is called on the final, actual Function object. Note
12576 * that the "prototype" property is looked up *only* from the
12577 * final object, *before* calling the constructor.
12578 *
12579 * Currently we follow the bound function chain here to get the
12580 * "prototype" property value from the final, non-bound function.
12581 * However, we let duk_handle_call() handle the argument "piling"
12582 * when the constructor is called. The bound function chain is
12583 * thus now processed twice.
12584 *
12585 * When constructing new Array instances, an unnecessary object is
12586 * created and discarded now: the standard [[Construct]] creates an
12587 * object, and calls the Array constructor. The Array constructor
12588 * returns an Array instance, which is used as the result value for
12589 * the "new" operation; the object created before the Array constructor
12590 * call is discarded.
12591 *
12592 * This would be easy to fix, e.g. by knowing that the Array constructor
12593 * will always create a replacement object and skip creating the fallback
12594 * object in that case.
12595 *
12596 * Note: functions called via "new" need to know they are called as a
12597 * constructor. For instance, built-in constructors behave differently
12598 * depending on how they are called.
12599 */
12600
12601 /* XXX: merge this with duk_js_call.c, as this function implements
12602 * core semantics (or perhaps merge the two files altogether).
12603 */
12604
12605 duk_hthread *thr = (duk_hthread *) ctx;
12607 duk_hobject *cons;
12608 duk_hobject *fallback;
12609 duk_idx_t idx_cons;
12610 duk_small_uint_t call_flags;
12611
12613
12614 /* [... constructor arg1 ... argN] */
12615
12616 idx_cons = duk_require_normalize_index(ctx, -nargs - 1);
12617
12618 DUK_DDD(DUK_DDDPRINT("top=%ld, nargs=%ld, idx_cons=%ld",
12619 (long) duk_get_top(ctx), (long) nargs, (long) idx_cons));
12620
12621 /* XXX: code duplication */
12622
12623 /*
12624 * Figure out the final, non-bound constructor, to get "prototype"
12625 * property.
12626 */
12627
12628 duk_dup(ctx, idx_cons);
12629 for (;;) {
12630 duk_tval *tv;
12631 tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
12632 DUK_ASSERT(tv != NULL);
12633
12634 if (DUK_TVAL_IS_OBJECT(tv)) {
12635 cons = DUK_TVAL_GET_OBJECT(tv);
12636 DUK_ASSERT(cons != NULL);
12638 /* Checking callability of the immediate target
12639 * is important, same for constructability.
12640 * Checking it for functions down the bound
12641 * function chain is not strictly necessary
12642 * because .bind() should normally reject them.
12643 * But it's good to check anyway because it's
12644 * technically possible to edit the bound function
12645 * chain via internal keys.
12646 */
12647 goto not_constructable;
12648 }
12649 if (!DUK_HOBJECT_HAS_BOUND(cons)) {
12650 break;
12651 }
12652 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
12653 /* Lightfuncs cannot be bound. */
12654 break;
12655 } else {
12656 /* Anything else is not constructable. */
12657 goto not_constructable;
12658 }
12659 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_TARGET); /* -> [... cons target] */
12660 duk_remove(ctx, -2); /* -> [... target] */
12661 }
12662 DUK_ASSERT(duk_is_callable(ctx, -1));
12663 DUK_ASSERT(duk_is_lightfunc(ctx, -1) ||
12664 (duk_get_hobject(ctx, -1) != NULL && !DUK_HOBJECT_HAS_BOUND(duk_get_hobject(ctx, -1))));
12665
12666 /* [... constructor arg1 ... argN final_cons] */
12667
12668 /*
12669 * Create "fallback" object to be used as the object instance,
12670 * unless the constructor returns a replacement value.
12671 * Its internal prototype needs to be set based on "prototype"
12672 * property of the constructor.
12673 */
12674
12675 duk_push_object(ctx); /* class Object, extensible */
12676
12677 /* [... constructor arg1 ... argN final_cons fallback] */
12678
12680 proto = duk_get_hobject(ctx, -1);
12681 if (!proto) {
12682 DUK_DDD(DUK_DDDPRINT("constructor has no 'prototype' property, or value not an object "
12683 "-> leave standard Object prototype as fallback prototype"));
12684 } else {
12685 DUK_DDD(DUK_DDDPRINT("constructor has 'prototype' property with object value "
12686 "-> set fallback prototype to that value: %!iO", (duk_heaphdr *) proto));
12687 fallback = duk_get_hobject(ctx, -2);
12688 DUK_ASSERT(fallback != NULL);
12690 }
12691 duk_pop(ctx);
12692
12693 /* [... constructor arg1 ... argN final_cons fallback] */
12694
12695 /*
12696 * Manipulate callstack for the call.
12697 */
12698
12699 duk_dup_top(ctx);
12700 duk_insert(ctx, idx_cons + 1); /* use fallback as 'this' value */
12701 duk_insert(ctx, idx_cons); /* also stash it before constructor,
12702 * in case we need it (as the fallback value)
12703 */
12704 duk_pop(ctx); /* pop final_cons */
12705
12706
12707 /* [... fallback constructor fallback(this) arg1 ... argN];
12708 * Note: idx_cons points to first 'fallback', not 'constructor'.
12709 */
12710
12711 DUK_DDD(DUK_DDDPRINT("before call, idx_cons+1 (constructor) -> %!T, idx_cons+2 (fallback/this) -> %!T, "
12712 "nargs=%ld, top=%ld",
12713 (duk_tval *) duk_get_tval(ctx, idx_cons + 1),
12714 (duk_tval *) duk_get_tval(ctx, idx_cons + 2),
12715 (long) nargs,
12716 (long) duk_get_top(ctx)));
12717
12718 /*
12719 * Call the constructor function (called in "constructor mode").
12720 */
12721
12722 call_flags = DUK_CALL_FLAG_CONSTRUCTOR_CALL; /* not protected, respect reclimit, is a constructor call */
12723
12724 duk_handle_call_unprotected(thr, /* thread */
12725 nargs, /* num_stack_args */
12726 call_flags); /* call_flags */
12727
12728 /* [... fallback retval] */
12729
12730 DUK_DDD(DUK_DDDPRINT("constructor call finished, fallback=%!iT, retval=%!iT",
12731 (duk_tval *) duk_get_tval(ctx, -2),
12732 (duk_tval *) duk_get_tval(ctx, -1)));
12733
12734 /*
12735 * Determine whether to use the constructor return value as the created
12736 * object instance or not.
12737 */
12738
12739 if (duk_is_object(ctx, -1)) {
12740 duk_remove(ctx, -2);
12741 } else {
12742 duk_pop(ctx);
12743 }
12744
12745 /*
const char * proto
Definition civetweb.c:18378
#define DUK_HOBJECT_HAS_BOUND(h)
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
#define DUK_CALL_FLAG_CONSTRUCTOR_CALL
DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs)
#define DUK_TVAL_IS_OBJECT(tv)
#define DUK_HOBJECT_HAS_CONSTRUCTABLE(h)
DUK_EXTERNAL void duk_remove(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, p)
DUK_EXTERNAL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_IS_LIGHTFUNC(tv)
DUK_EXTERNAL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_idx_t duk_push_object(duk_context *ctx)
DUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_index)
DUK_EXTERNAL duk_idx_t duk_get_top(duk_context *ctx)
#define DUK_STRIDX_INT_TARGET
DUK_INTERNAL_DECL duk_int_t duk_handle_safe_call(duk_hthread *thr, duk_safe_call_function func, duk_idx_t num_stack_args, duk_idx_t num_stack_res)
#define DUK_GET_TVAL_NEGIDX(ctx, idx)
DUK_EXTERNAL void duk_pop(duk_context *ctx)
#define duk_is_callable(ctx, index)

◆ duk_next()

DUK_EXTERNAL_DECL duk_bool_t duk_next ( duk_context * ctx,
duk_idx_t enum_index,
duk_bool_t get_value )

Definition at line 14727 of file duktape-1.5.2/src-noline/duktape.c.

14728 {
14729 /* Note: this may fail, caller should protect the call if necessary */
14730 duk_hobject_compact_props(thr, obj);
14731 }
14732}
14733
DUK_INTERNAL_DECL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj)

◆ duk_normalize_index()

DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15056 of file duktape-1.5.2/src-noline/duktape.c.

15057 {
15059 /* not reachable */
15060 }
15061 return 0;
15062}
15063
15064/*
15065 * Stack index validation/normalization and getting a stack duk_tval ptr.
15066 *
15067 * These are called by many API entrypoints so the implementations must be
15068 * fast and "inlined".
15069 *
15070 * There's some repetition because of this; keep the functions in sync.
15071 */
15072
15074 duk_hthread *thr = (duk_hthread *) ctx;
15075 duk_uidx_t vs_size;
15076 duk_uidx_t uindex;
15077
15080
15081 /* Care must be taken to avoid pointer wrapping in the index
15082 * validation. For instance, on a 32-bit platform with 8-byte
15083 * duk_tval the index 0x20000000UL would wrap the memory space
15084 * once.
15085 */
15086
15087 /* Assume value stack sizes (in elements) fits into duk_idx_t. */
15089 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15090 DUK_ASSERT_DISABLE(vs_size >= 0); /* unsigned */

◆ duk_pcall()

DUK_EXTERNAL_DECL duk_int_t duk_pcall ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12427 of file duktape-1.5.2/src-noline/duktape.c.

12427 {
12428 /*
12429 * XXX: if duk_handle_call() took values through indices, this could be
12430 * made much more sensible. However, duk_handle_call() needs to fudge
12431 * the 'this' and 'func' values to handle bound function chains, which
12432 * is now done "in-place", so this is not a trivial change.
12433 */
12434
12436
12437 obj_index = duk_require_normalize_index(ctx, obj_index); /* make absolute */
12438
12439 duk__call_prop_prep_stack(ctx, obj_index, nargs);
12440
12441 duk_call_method(ctx, nargs);
12442}
12443
12445 duk_hthread *thr = (duk_hthread *) ctx;
12446 duk_small_uint_t call_flags;
12447 duk_idx_t idx_func;
12448 duk_int_t rc;
12449
12451 DUK_ASSERT(thr != NULL);
12452
12453 idx_func = duk_get_top(ctx) - nargs - 1; /* must work for nargs <= 0 */
12454 if (idx_func < 0 || nargs < 0) {
12455 /* We can't reliably pop anything here because the stack input
12456 * shape is incorrect. So we throw an error; if the caller has
12457 * no catch point for this, a fatal error will occur. Another
12458 * alternative would be to just return an error. But then the
12459 * stack would be in an unknown state which might cause some
12460 * very hard to diagnose problems later on. Also note that even
12461 * if we did not throw an error here, the underlying call handler
12462 * might STILL throw an out-of-memory error or some other internal
12463 * fatal error.
DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_index, duk_idx_t nargs)
DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs)
DUK_EXTERNAL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs)

◆ duk_pcall_method()

DUK_EXTERNAL_DECL duk_int_t duk_pcall_method ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12465 of file duktape-1.5.2/src-noline/duktape.c.

12482 {
12483 duk_hthread *thr = (duk_hthread *) ctx;
12484 duk_small_uint_t call_flags;
12485 duk_idx_t idx_func;
12486 duk_int_t rc;
12487

◆ duk_pcall_prop()

DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_idx_t nargs )

Definition at line 12510 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_pnew()

DUK_EXTERNAL_DECL duk_int_t duk_pnew ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12757 of file duktape-1.5.2/src-noline/duktape.c.

12760 :
12762}
12763
12765 duk_uint_t nargs;
12766
12767 nargs = duk_to_uint(ctx, -1);
12768 duk_pop(ctx);
12769
12770 duk_new(ctx, nargs);
12771 return 1;
12772}
12773
duk_small_int_t duk_ret_t
DUK_LOCAL duk_ret_t duk__pnew_helper(duk_context *ctx)
#define DUK_STR_NOT_CONSTRUCTABLE
DUK_EXTERNAL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index)

◆ duk_pop()

DUK_EXTERNAL_DECL void duk_pop ( duk_context * ctx)

Definition at line 19146 of file duktape-1.5.2/src-noline/duktape.c.

19158 {
19160 duk_pop_n(ctx, 1);
19161}
19162#else
19163DUK_EXTERNAL void duk_pop(duk_context *ctx) {
19164 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_pop_2()

DUK_EXTERNAL_DECL void duk_pop_2 ( duk_context * ctx)

Definition at line 19167 of file duktape-1.5.2/src-noline/duktape.c.

19169 {

◆ duk_pop_3()

DUK_EXTERNAL_DECL void duk_pop_3 ( duk_context * ctx)

Definition at line 19172 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_pop_n()

DUK_EXTERNAL_DECL void duk_pop_n ( duk_context * ctx,
duk_idx_t count )

Definition at line 19088 of file duktape-1.5.2/src-noline/duktape.c.

19092 {
19093 duk_hthread *thr = (duk_hthread *) ctx;
19095 DUK_ASSERT(thr != NULL);
19096 DUK_ASSERT(builtin_idx >= 0 && builtin_idx < DUK_NUM_BUILTINS);
19097 DUK_ASSERT(thr->builtins[builtin_idx] != NULL);
19098 duk_push_hobject(ctx, thr->builtins[builtin_idx]);
19099}
19100
19101/*
19102 * Poppers
19103 */
19104
19105DUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count) {
19106 duk_hthread *thr = (duk_hthread *) ctx;
19107 duk_tval *tv;
19108
19110
19111 if (DUK_UNLIKELY(count < 0)) {
19113 return;
19114 }
19115
19117 if (DUK_UNLIKELY((duk_size_t) (thr->valstack_top - thr->valstack_bottom) < (duk_size_t) count)) {
19119 }
19120
19121 /*
19122 * Must be very careful here, every DECREF may cause reallocation
19123 * of our valstack.
19124 */
19125
19126 /* XXX: inlined DECREF macro would be nice here: no NULL check,
19127 * refzero queueing but no refzero algorithm run (= no pointer
19128 * instability), inline code.
19129 */
19130
19131 /* XXX: optimize loops */
19132
19133#if defined(DUK_USE_REFERENCE_COUNTING)
19134 while (count > 0) {
19135 count--;
#define DUK_STR_INVALID_COUNT
DUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h)

◆ duk_push_array()

DUK_EXTERNAL_DECL duk_idx_t duk_push_array ( duk_context * ctx)

Definition at line 18458 of file duktape-1.5.2/src-noline/duktape.c.

18466 {
18468
18469 return duk_push_object_helper(ctx,
18473}
18474
18476 duk_hthread *thr = (duk_hthread *) ctx;
18477 duk_hobject *obj;
18478 duk_idx_t ret;
18479
18481
18482 ret = duk_push_object_helper(ctx,
18487
18488 obj = duk_require_hobject(ctx, ret);
18489
18490 /*
18491 * An array must have a 'length' property (E5 Section 15.4.5.2).
18492 * The special array behavior flag must only be enabled once the
18493 * length property has been added.
18494 *
#define DUK_HOBJECT_CLASS_OBJECT
#define DUK_BIDX_OBJECT_PROTOTYPE
#define DUK_HOBJECT_CLASS_AS_FLAGS(v)
#define DUK_BIDX_ARRAY_PROTOTYPE
#define DUK_HOBJECT_FLAG_EXTENSIBLE
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
DUK_EXTERNAL duk_idx_t duk_push_array(duk_context *ctx)
#define DUK_HOBJECT_FLAG_ARRAY_PART

◆ duk_push_boolean()

DUK_EXTERNAL_DECL void duk_push_boolean ( duk_context * ctx,
duk_bool_t val )

Definition at line 17873 of file duktape-1.5.2/src-noline/duktape.c.

17879 {
17880 duk_hthread *thr;
17881 duk_tval *tv_slot;
17882
17884 thr = (duk_hthread *) ctx;

◆ duk_push_buffer_object()

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 )

Definition at line 18794 of file duktape-1.5.2/src-noline/duktape.c.

18805 {
18807};
18808#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
18809#undef DUK__PACK_ARGS
18810
18811DUK_EXTERNAL 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) {
18812 duk_hthread *thr;
18813 duk_hbufferobject *h_bufobj;
18814 duk_hbuffer *h_val;
18815 duk_uint32_t tmp;
18816 duk_uint_t classnum;
18817 duk_uint_t protobidx;
18818 duk_uint_t lookupidx;
18819 duk_uint_t uint_offset, uint_length, uint_added;
18820
18822 thr = (duk_hthread *) ctx;
18823 DUK_UNREF(thr);
18824
18825 /* The underlying types for offset/length in duk_hbufferobject is
18826 * duk_uint_t; make sure argument values fit and that offset + length
18827 * does not wrap.
18828 */
18829 uint_offset = (duk_uint_t) byte_offset;
18830 uint_length = (duk_uint_t) byte_length;
18831 if (sizeof(duk_size_t) != sizeof(duk_uint_t)) {
18832 if ((duk_size_t) uint_offset != byte_offset || (duk_size_t) uint_length != byte_length) {
18833 goto range_error;
18834 }
18835 }
18836 uint_added = uint_offset + uint_length;
18837 if (uint_added < uint_offset) {
18838 goto range_error;
18839 }
18840 DUK_ASSERT(uint_added >= uint_offset && uint_added >= uint_length);
18841
18842 DUK_ASSERT_DISABLE(flags >= 0); /* flags is unsigned */
18843 lookupidx = flags & 0x0f; /* 4 low bits */
18844 if (lookupidx >= sizeof(duk__bufobj_flags_lookup) / sizeof(duk_uint32_t)) {
18845 goto arg_error;
18846 }
18847 tmp = duk__bufobj_flags_lookup[lookupidx];
18848 classnum = tmp >> 24;
18849 protobidx = (tmp >> 16) & 0xff;
18850
18851 h_val = duk_require_hbuffer(ctx, idx_buffer);
18852 DUK_ASSERT(h_val != NULL);
18853
18854 h_bufobj = duk_push_bufferobject_raw(ctx,
18858 protobidx);
18859 DUK_ASSERT(h_bufobj != NULL);
18860
18861 h_bufobj->buf = h_val;
18862 DUK_HBUFFER_INCREF(thr, h_val);
18863 h_bufobj->offset = uint_offset;
18864 h_bufobj->length = uint_length;
18865 h_bufobj->shift = (tmp >> 4) & 0x0f;
18866 h_bufobj->elem_type = (tmp >> 8) & 0xff;
18867 h_bufobj->is_view = tmp & 0x0f;
18869
18870#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
18871 /* TypedArray views need an automatic ArrayBuffer which must be
18872 * provided as .buffer property of the view. Just create a new
18873 * ArrayBuffer sharing the same underlying buffer.
18874 */
18875 if (flags & DUK_BUFOBJ_CREATE_ARRBUF) {
18876 h_bufobj = duk_push_bufferobject_raw(ctx,
18881
18882 DUK_ASSERT(h_bufobj != NULL);
18883
18884 h_bufobj->buf = h_val;
18885 DUK_HBUFFER_INCREF(thr, h_val);
18886 h_bufobj->offset = uint_offset;
18887 h_bufobj->length = uint_length;
18888 DUK_ASSERT(h_bufobj->shift == 0);
18890 DUK_ASSERT(h_bufobj->is_view == 0);
#define DUK_BIDX_ARRAYBUFFER_PROTOTYPE
#define DUK_HOBJECT_CLASS_BUFFER
#define DUK_HBUFFER_INCREF(thr, h)
#define DUK__PACK_ARGS(classnum, protobidx, elemtype, elemshift, isview)
#define DUK_ASSERT_HBUFFEROBJECT_VALID(h)
#define DUK_HOBJECT_FLAG_BUFFEROBJECT
DUK_EXTERNAL 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)
static const duk_uint32_t duk__bufobj_flags_lookup[]
DUK_INTERNAL_DECL duk_hbuffer * duk_require_hbuffer(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hbufferobject * duk_push_bufferobject_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
#define DUK_BIDX_BUFFER_PROTOTYPE
#define DUK_HOBJECT_CLASS_ARRAYBUFFER
#define DUK_HBUFFEROBJECT_ELEM_UINT8
#define DUK_BUFOBJ_CREATE_ARRBUF

◆ duk_push_buffer_raw()

DUK_EXTERNAL_DECL void * duk_push_buffer_raw ( duk_context * ctx,
duk_size_t size,
duk_small_uint_t flags )

Definition at line 18974 of file duktape-1.5.2/src-noline/duktape.c.

18974 {
18975 const char *filename = duk_api_global_filename;
18977 va_list ap;
18978 duk_idx_t ret;
18979
18981
18984 va_start(ap, fmt);
18985 ret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);
18986 va_end(ap);
18987 return ret;
18988}
18989#endif /* DUK_USE_VARIADIC_MACROS */
18990
18992 duk_hthread *thr = (duk_hthread *) ctx;
18993 duk_tval *tv_slot;
18994 duk_hbuffer *h;
18995 void *buf_data;
18996
18998
18999 /* check stack first */
19000 if (thr->valstack_top >= thr->valstack_end) {
19002 }
19003
DUK_EXTERNAL duk_int_t duk_api_global_line
DUK_EXTERNAL 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)
DUK_EXTERNAL const char * duk_api_global_filename
#define DUK_STR_PUSH_BEYOND_ALLOC_STACK

◆ duk_push_c_function()

DUK_EXTERNAL_DECL duk_idx_t duk_push_c_function ( duk_context * ctx,
duk_c_function func,
duk_idx_t nargs )

Definition at line 18650 of file duktape-1.5.2/src-noline/duktape.c.

18662 :
18664 return 0; /* not reached */
18665}

◆ duk_push_c_lightfunc()

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 )

Definition at line 18698 of file duktape-1.5.2/src-noline/duktape.c.

18700 {
18701 duk_uint_t flags;
18702
18704
18711
18712 (void) duk__push_c_function_raw(ctx, func, nargs, flags);
18713}
18714
18716 duk_hthread *thr = (duk_hthread *) ctx;
18717 duk_tval tv_tmp;
18718 duk_small_uint_t lf_flags;
18719
18721
18722 /* check stack first */
18723 if (thr->valstack_top >= thr->valstack_end) {
18725 }
18726
18727 if (nargs >= DUK_LFUNC_NARGS_MIN && nargs <= DUK_LFUNC_NARGS_MAX) {
18728 /* as is */
18729 } else if (nargs == DUK_VARARGS) {
18731 } else {
18732 goto api_error;
18733 }
#define DUK_HOBJECT_FLAG_NEWENV
#define DUK_LFUNC_NARGS_MAX
#define DUK_HOBJECT_FLAG_NOTAIL
#define DUK_HOBJECT_CLASS_FUNCTION
#define DUK_LFUNC_NARGS_VARARGS
DUK_EXTERNAL 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)
DUK_LOCAL_DECL duk_idx_t duk__push_c_function_raw(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_uint_t flags)
#define DUK_HOBJECT_FLAG_STRICT
#define DUK_HOBJECT_FLAG_NATIVEFUNCTION
#define DUK_LFUNC_NARGS_MIN

◆ duk_push_context_dump()

DUK_EXTERNAL_DECL void duk_push_context_dump ( duk_context * ctx)

Definition at line 13718 of file duktape-1.5.2/src-noline/duktape.c.

13735 {
13736 duk_idx_t idx;
13737 duk_idx_t top;
13738
13740
13741 /* We don't duk_require_stack() here now, but rely on the caller having
13742 * enough space.
13743 */
13744
13745 top = duk_get_top(ctx);
13746 duk_push_array(ctx);
13747 for (idx = 0; idx < top; idx++) {
13748 duk_dup(ctx, idx);
13749 duk_put_prop_index(ctx, -2, idx);
13750 }
DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx)

◆ duk_push_current_function()

DUK_EXTERNAL_DECL void duk_push_current_function ( duk_context * ctx)

Definition at line 18220 of file duktape-1.5.2/src-noline/duktape.c.

18224 {
18225 duk_hthread *thr;
18226
18227 DUK_ASSERT(ctx != NULL);
18228 thr = (duk_hthread *) ctx;
18229
18230 DUK_ASSERT(thr->callstack_top > 0); /* caller required to know */
18231 DUK_ASSERT(thr->valstack_bottom > thr->valstack); /* consequence of above */
18232 DUK_ASSERT(thr->valstack_bottom - 1 >= thr->valstack); /* 'this' binding exists */
18233
18234 return thr->valstack_bottom - 1;
18235}

◆ duk_push_current_thread()

DUK_EXTERNAL_DECL void duk_push_current_thread ( duk_context * ctx)

Definition at line 18237 of file duktape-1.5.2/src-noline/duktape.c.

18237 {
18238 duk_hthread *thr = (duk_hthread *) ctx;
18239 duk_activation *act;
18240
18242 DUK_ASSERT(thr != NULL);
18245
18247 if (act) {
18248 duk_push_tval(ctx, &act->tv_func);
DUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv)

◆ duk_push_error_object_raw()

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,
... )

Definition at line 18944 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_push_error_object_stash()

DUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash ( duk_context * ctx,
duk_errcode_t err_code,
const char * fmt,
... )

Definition at line 18957 of file duktape-1.5.2/src-noline/duktape.c.

18961 {
18962 va_list ap;
18963 duk_idx_t ret;
18964
18966
18967 va_start(ap, fmt);
18968 ret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);
18969 va_end(ap);
18970 return ret;
18971}

◆ duk_push_error_object_va_raw()

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 )

Definition at line 18892 of file duktape-1.5.2/src-noline/duktape.c.

18900 :
18902 return; /* not reached */
18903
18904 arg_error:
18906 return; /* not reached */
18907}
18908
18909DUK_EXTERNAL 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) {
18910 duk_hthread *thr = (duk_hthread *) ctx;
18911 duk_idx_t ret;
18913#ifdef DUK_USE_AUGMENT_ERROR_CREATE
18914 duk_bool_t noblame_fileline;
18915#endif
18916
18918 DUK_ASSERT(thr != NULL);
18919 DUK_UNREF(filename);
18920 DUK_UNREF(line);
18921
18922 /* Error code also packs a tracedata related flag. */
18923#ifdef DUK_USE_AUGMENT_ERROR_CREATE
18924 noblame_fileline = err_code & DUK_ERRCODE_FLAG_NOBLAME_FILELINE;
18925#endif
18926 err_code = err_code & (~DUK_ERRCODE_FLAG_NOBLAME_FILELINE);
18927
18928 /* error gets its 'name' from the prototype */
18929 proto = duk_error_prototype_from_code(thr, err_code);
18933 proto);
18934
18935 /* ... and its 'message' from an instance property */
18936 if (fmt) {
18937 duk_push_vsprintf(ctx, fmt, ap);
18939 } else {
18940 /* If no explicit message given, put error code into message field
18941 * (as a number). This is not fully in keeping with the Ecmascript
18942 * error model because messages are supposed to be strings (Error
#define DUK_ERROR_RANGE(thr, msg)
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto)
DUK_INTERNAL_DECL duk_hobject * duk_error_prototype_from_code(duk_hthread *thr, duk_errcode_t err_code)
#define DUK_HOBJECT_CLASS_ERROR
DUK_EXTERNAL const char * duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap)
#define DUK_PROPDESC_FLAGS_WC
DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)
#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE

◆ duk_push_false()

DUK_EXTERNAL_DECL void duk_push_false ( duk_context * ctx)

Definition at line 17897 of file duktape-1.5.2/src-noline/duktape.c.

17898 : 0); /* ensure value is 1 or 0 (not other non-zero) */
17899 tv_slot = thr->valstack_top++;
17900 DUK_TVAL_SET_BOOLEAN(tv_slot, b);
17901}
17902
17904 duk_hthread *thr;
17905 duk_tval *tv_slot;
17906
DUK_EXTERNAL void duk_push_true(duk_context *ctx)
#define DUK_TVAL_SET_BOOLEAN(tv, val)

◆ duk_push_global_object()

DUK_EXTERNAL_DECL void duk_push_global_object ( duk_context * ctx)

Definition at line 18250 of file duktape-1.5.2/src-noline/duktape.c.

18254 {

◆ duk_push_global_stash()

DUK_EXTERNAL_DECL void duk_push_global_stash ( duk_context * ctx)

Definition at line 18279 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_push_heap_stash()

DUK_EXTERNAL_DECL void duk_push_heap_stash ( duk_context * ctx)

Definition at line 18269 of file duktape-1.5.2/src-noline/duktape.c.

18274 {
18277 DUK_DDD(DUK_DDDPRINT("creating heap/global/thread stash on first use"));

◆ duk_push_heapptr()

DUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr ( duk_context * ctx,
void * ptr )

Definition at line 19005 of file duktape-1.5.2/src-noline/duktape.c.

19005 {
19007 }
19008
19009 h = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data);
19010 if (!h) {
19012 }
19013
19014 tv_slot = thr->valstack_top;
19015 DUK_TVAL_SET_BUFFER(tv_slot, h);
19016 DUK_HBUFFER_INCREF(thr, h);
19017 thr->valstack_top++;
19018
19019 return (void *) buf_data;
19020}
19021
19023 duk_hthread *thr = (duk_hthread *) ctx;
19024 duk_idx_t ret;
19025
19027
19028 ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
19029
19030 if (ptr == NULL) {
19031 goto push_undefined;
19032 }
19033
19034 switch ((int) DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) ptr)) {
19035 case DUK_HTYPE_STRING:
#define DUK_HEAPHDR_GET_TYPE(h)
#define DUK_TVAL_SET_BUFFER(tv, hptr)
#define DUK_STR_BUFFER_TOO_LONG
DUK_INTERNAL_DECL duk_hbuffer * duk_hbuffer_alloc(duk_heap *heap, duk_size_t size, duk_small_uint_t flags, void **out_bufdata)
DUK_EXTERNAL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr)

◆ duk_push_int()

DUK_EXTERNAL_DECL void duk_push_int ( duk_context * ctx,
duk_int_t val )

Definition at line 17923 of file duktape-1.5.2/src-noline/duktape.c.

17926 {
17927 duk_hthread *thr;
17928 duk_tval *tv_slot;
17930
17932 thr = (duk_hthread *) ctx;
17934 du.d = val;
17936 tv_slot = thr->valstack_top++;
17937 DUK_TVAL_SET_NUMBER(tv_slot, du.d);
17938}
17939
17941#if defined(DUK_USE_FASTINT)
17942 duk_hthread *thr;
17943 duk_tval *tv_slot;
17944
17946 thr = (duk_hthread *) ctx;
17948 tv_slot = thr->valstack_top++;
17949#if DUK_INT_MAX <= 0x7fffffffL
17950 DUK_TVAL_SET_FASTINT_I32(tv_slot, (duk_int32_t) val);
17951#else
17952 if (val >= DUK_FASTINT_MIN && val <= DUK_FASTINT_MAX) {
17953 DUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);
17954 } else {
DUK_EXTERNAL void duk_push_int(duk_context *ctx, duk_int_t val)
#define DUK_TVAL_SET_FASTINT(tv, val)
#define DUK_TVAL_SET_FASTINT_I32(tv, val)
#define DUK_TVAL_SET_NUMBER(tv, val)
#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)

◆ duk_push_lstring()

DUK_EXTERNAL_DECL const char * duk_push_lstring ( duk_context * ctx,
const char * str,
duk_size_t len )

Definition at line 18004 of file duktape-1.5.2/src-noline/duktape.c.

18007 {
18008 duk_hthread *thr;
18009 duk_tval *tv_slot;
18011
18013 thr = (duk_hthread *) ctx;
18017 tv_slot = thr->valstack_top++;
18018 DUK_TVAL_SET_NUMBER(tv_slot, du.d);
18019}
18020
18021DUK_EXTERNAL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len) {
18022 duk_hthread *thr = (duk_hthread *) ctx;
18023 duk_hstring *h;
18024 duk_tval *tv_slot;
18025
18027
18028 /* check stack before interning (avoid hanging temp) */
18029 if (thr->valstack_top >= thr->valstack_end) {
18031 }
18032
18033 /* NULL with zero length represents an empty string; NULL with higher
18034 * length is also now trated like an empty string although it is
18035 * a bit dubious. This is unlike duk_push_string() which pushes a
18036 * 'null' if the input string is a NULL.
18037 */
18038 if (!str) {
DUK_EXTERNAL const char * duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len)
#define DUK_DBLUNION_SET_NAN(u)
#define DUK_DBLUNION_IS_NORMALIZED(u)

◆ duk_push_nan()

DUK_EXTERNAL_DECL void duk_push_nan ( duk_context * ctx)

Definition at line 17990 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_push_null()

DUK_EXTERNAL_DECL void duk_push_null ( duk_context * ctx)

Definition at line 17862 of file duktape-1.5.2/src-noline/duktape.c.

17865 {
17866 duk_hthread *thr;
17867
17869 thr = (duk_hthread *) ctx;
17871

◆ duk_push_number()

DUK_EXTERNAL_DECL void duk_push_number ( duk_context * ctx,
duk_double_t val )

Definition at line 17909 of file duktape-1.5.2/src-noline/duktape.c.

17914 {
17915 duk_hthread *thr;
17916 duk_tval *tv_slot;
17917
17919 thr = (duk_hthread *) ctx;
17921 tv_slot = thr->valstack_top++;

◆ duk_push_object()

DUK_EXTERNAL_DECL duk_idx_t duk_push_object ( duk_context * ctx)

Definition at line 18449 of file duktape-1.5.2/src-noline/duktape.c.

18451 {
18452 duk_hthread *thr = (duk_hthread *) ctx;
18453 duk_idx_t ret;
18454 duk_hobject *h;
18455

◆ duk_push_pointer()

DUK_EXTERNAL_DECL void duk_push_pointer ( duk_context * ctx,
void * p )

Definition at line 18121 of file duktape-1.5.2/src-noline/duktape.c.

18122 {
18123 duk_hthread *thr = (duk_hthread *) ctx;
18125 DUK_UNREF(path);
18126
18127 if (flags != 0) {
18128 DUK_ASSERT(flags == DUK_STRING_PUSH_SAFE); /* only flag now */
18129 duk_push_undefined(ctx);
18130 } else {
DUK_EXTERNAL void duk_push_undefined(duk_context *ctx)

◆ duk_push_sprintf()

DUK_EXTERNAL_DECL const char * duk_push_sprintf ( duk_context * ctx,
const char * fmt,
... )

Definition at line 18380 of file duktape-1.5.2/src-noline/duktape.c.

18382 {
18384 }
18385 }
18386
18387 /* Cannot use duk_to_string() on the buffer because it is usually
18388 * larger than 'len'. Also, 'buf' is usually a stack buffer.
18389 */
18390 res = duk_push_lstring(ctx, (const char *) buf, (duk_size_t) len); /* [ buf? res ] */
18391 if (pushed_buf) {
18392 duk_remove(ctx, -2);
#define DUK_STR_SPRINTF_TOO_LONG

◆ duk_push_string()

DUK_EXTERNAL_DECL const char * duk_push_string ( duk_context * ctx,
const char * str )

Definition at line 18040 of file duktape-1.5.2/src-noline/duktape.c.

18043 {
18045 }
18046
18047 h = duk_heap_string_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len);
18048 DUK_ASSERT(h != NULL);
18049
#define DUK_STR_STRING_TOO_LONG
DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len)

◆ duk_push_string_file_raw()

DUK_EXTERNAL_DECL const char * duk_push_string_file_raw ( duk_context * ctx,
const char * path,
duk_uint_t flags )

Definition at line 18056 of file duktape-1.5.2/src-noline/duktape.c.

18057 {
18059
18060 if (str) {
18061 return duk_push_lstring(ctx, str, DUK_STRLEN(str));
18062 } else {
18063 duk_push_null(ctx);
18064 return NULL;
18065 }
18066}
18067
18068#ifdef DUK_USE_FILE_IO
18069/* This is a bit clunky because it is ANSI C portable. Should perhaps
18070 * relocate to another file because this is potentially platform
18071 * dependent.
18072 */
18073DUK_EXTERNAL const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags) {
18074 duk_hthread *thr = (duk_hthread *) ctx;
18075 duk_file *f = NULL;
18076 char *buf;
18077 long sz; /* ANSI C typing */
18078
18080
18081 if (!path) {
18082 goto fail;
18083 }
18084 f = DUK_FOPEN(path, "rb");
18085 if (!f) {
18086 goto fail;
18087 }
18088 if (DUK_FSEEK(f, 0, SEEK_END) < 0) {
18089 goto fail;
18090 }
18091 sz = DUK_FTELL(f);
18092 if (sz < 0) {
18093 goto fail;
18094 }
18095 if (DUK_FSEEK(f, 0, SEEK_SET) < 0) {
18096 goto fail;
18097 }
18098 buf = (char *) duk_push_fixed_buffer(ctx, (duk_size_t) sz);
18099 DUK_ASSERT(buf != NULL);
18100 if ((duk_size_t) DUK_FREAD(buf, 1, (size_t) sz, f) != (duk_size_t) sz) {
18101 goto fail;
18102 }
18103 (void) DUK_FCLOSE(f); /* ignore fclose() error */
DUK_EXTERNAL const char * duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags)
DUK_EXTERNAL void duk_push_null(duk_context *ctx)

◆ duk_push_this()

DUK_EXTERNAL_DECL void duk_push_this ( duk_context * ctx)

Definition at line 18171 of file duktape-1.5.2/src-noline/duktape.c.

18174 {
18175 /* XXX: better macro for DUK_TVAL_IS_UNDEFINED_OR_NULL(tv) */

◆ duk_push_thread_raw()

DUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw ( duk_context * ctx,
duk_uint_t flags )

Definition at line 18496 of file duktape-1.5.2/src-noline/duktape.c.

18513 {
18514 duk_hthread *thr = (duk_hthread *) ctx;
18515 duk_hthread *obj;
18516 duk_idx_t ret;
18517 duk_tval *tv_slot;
18518
18520
18521 /* check stack first */
18522 if (thr->valstack_top >= thr->valstack_end) {
18524 }
18525
18526 obj = duk_hthread_alloc(thr->heap,
18530 if (!obj) {
18532 }
18534#if defined(DUK_USE_ROM_STRINGS)
18535 /* Nothing to initialize, strs[] is in ROM. */
18536#else
18537#if defined(DUK_USE_HEAPPTR16)
18538 obj->strs16 = thr->strs16;
18539#else
18540 obj->strs = thr->strs;
18541#endif
18542#endif
18543 DUK_DDD(DUK_DDDPRINT("created thread object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags));
18544
18545 /* make the new thread reachable */
18546 tv_slot = thr->valstack_top;
18547 DUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);
18548 DUK_HTHREAD_INCREF(thr, obj);
18549 ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
18550 thr->valstack_top++;
18551
18552 /* important to do this *after* pushing, to make the thread reachable for gc */
18553 if (!duk_hthread_init_stacks(thr->heap, obj)) {
18555 }
18556
18557 /* initialize built-ins - either by copying or creating new ones */
#define DUK_TVAL_SET_OBJECT(tv, hptr)
DUK_INTERNAL_DECL duk_hthread * duk_hthread_alloc(duk_heap *heap, duk_uint_t hobject_flags)
#define DUK_HTHREAD_STATE_INACTIVE
#define DUK_HTHREAD_INCREF(thr, h)
DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr)
#define DUK_HOBJECT_CLASS_THREAD
#define DUK_HOBJECT_FLAG_THREAD

◆ duk_push_thread_stash()

DUK_EXTERNAL_DECL void duk_push_thread_stash ( duk_context * ctx,
duk_context * target_ctx )

Definition at line 18285 of file duktape-1.5.2/src-noline/duktape.c.

18286 {
18287 duk_hthread *thr = (duk_hthread *) ctx;
18288 duk_heap *heap;
18290 heap = thr->heap;
18291 DUK_ASSERT(heap->heap_object != NULL);
18292 duk_push_hobject(ctx, heap->heap_object);
18293 duk__push_stash(ctx);
18294}
DUK_LOCAL void duk__push_stash(duk_context *ctx)

◆ duk_push_true()

DUK_EXTERNAL_DECL void duk_push_true ( duk_context * ctx)

Definition at line 17886 of file duktape-1.5.2/src-noline/duktape.c.

17890 {
17891 duk_hthread *thr;
17892 duk_tval *tv_slot;
17894

◆ duk_push_uint()

DUK_EXTERNAL_DECL void duk_push_uint ( duk_context * ctx,
duk_uint_t val )

Definition at line 17956 of file duktape-1.5.2/src-noline/duktape.c.

17973 {
17974#if defined(DUK_USE_FASTINT)
17975 duk_hthread *thr;
17976 duk_tval *tv_slot;
17977
17979 thr = (duk_hthread *) ctx;
17981 tv_slot = thr->valstack_top++;
17982#if DUK_UINT_MAX <= 0xffffffffUL
17983 DUK_TVAL_SET_FASTINT_U32(tv_slot, (duk_uint32_t) val);
17984#else
17985 if (val <= DUK_FASTINT_MAX) { /* val is unsigned so >= 0 */
17986 /* XXX: take advantage of val being unsigned, no need to mask */
17987 DUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);
17988 } else {
#define DUK_TVAL_SET_FASTINT_U32(tv, val)

◆ duk_push_undefined()

DUK_EXTERNAL_DECL void duk_push_undefined ( duk_context * ctx)

Definition at line 17848 of file duktape-1.5.2/src-noline/duktape.c.

17852 {
17853 duk_hthread *thr;
17854 duk_tval *tv_slot;
17855
17857 DUK_ASSERT(tv != NULL);
17858 thr = (duk_hthread *) ctx;
17860 tv_slot = thr->valstack_top++;

◆ duk_push_vsprintf()

DUK_EXTERNAL_DECL const char * duk_push_vsprintf ( duk_context * ctx,
const char * fmt,
va_list ap )

Definition at line 18314 of file duktape-1.5.2/src-noline/duktape.c.

18314 {
18315 duk_int_t len;
18316
18318 DUK_UNREF(ctx);
18319
18320 /* NUL terminator handling doesn't matter here */
18321 len = DUK_VSNPRINTF((char *) buf, sz, fmt, ap);
18322 if (len < (duk_int_t) sz) {
18323 /* Return value of 'sz' or more indicates output was (potentially)
18324 * truncated.
18325 */
18326 return (duk_int_t) len;
18327 }
18328 return -1;
18329}
18330
18331DUK_EXTERNAL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap) {
18332 duk_hthread *thr = (duk_hthread *) ctx;
18333 duk_uint8_t stack_buf[DUK_PUSH_SPRINTF_INITIAL_SIZE];
18335 duk_bool_t pushed_buf = 0;
18336 void *buf;
18337 duk_int_t len; /* XXX: duk_ssize_t */
18338 const char *res;
18339
18341
18342 /* special handling of fmt==NULL */
18343 if (!fmt) {
18344 duk_hstring *h_str;
18346 h_str = DUK_HTHREAD_STRING_EMPTY_STRING(thr); /* rely on interning, must be this string */
18347 return (const char *) DUK_HSTRING_GET_DATA(h_str);
18348 }
18349
18350 /* initial estimate based on format string */
18351 sz = DUK_STRLEN(fmt) + 16; /* format plus something to avoid just missing */
18354 }
18355 DUK_ASSERT(sz > 0);
18356
18357 /* Try to make do with a stack buffer to avoid allocating a temporary buffer.
18358 * This works 99% of the time which is quite nice.
18359 */
18360 for (;;) {
18361 va_list ap_copy; /* copied so that 'ap' can be reused */
18362
18363 if (sz <= sizeof(stack_buf)) {
18364 buf = stack_buf;
18365 } else if (!pushed_buf) {
18366 pushed_buf = 1;
18367 buf = duk_push_dynamic_buffer(ctx, sz);
18368 } else {
18369 buf = duk_resize_buffer(ctx, -1, sz);
18370 }
18371 DUK_ASSERT(buf != NULL);
18372
18373 DUK_VA_COPY(ap_copy, ap);
18374 len = duk__try_push_vsprintf(ctx, buf, sz, fmt, ap_copy);
18375 va_end(ap_copy);
18376 if (len >= 0) {
18377 break;
18378 }
#define DUK_VA_COPY(dest, src)
DUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_int_t stridx)
DUK_LOCAL duk_int_t duk__try_push_vsprintf(duk_context *ctx, void *buf, duk_size_t sz, const char *fmt, va_list ap)
#define DUK_PUSH_SPRINTF_INITIAL_SIZE
#define DUK_STRIDX_EMPTY_STRING
#define DUK_HTHREAD_STRING_EMPTY_STRING(thr)
#define duk_push_dynamic_buffer(ctx, size)

◆ duk_put_function_list()

DUK_EXTERNAL_DECL void duk_put_function_list ( duk_context * ctx,
duk_idx_t obj_index,
const duk_function_list_entry * funcs )

Definition at line 14739 of file duktape-1.5.2/src-noline/duktape.c.

14744 {
14746
14747 duk_require_hobject(ctx, enum_index);
14748 duk_dup(ctx, enum_index);
14749 return duk_hobject_enumerator_next(ctx, get_value);
14750}
14751
14752/*
DUK_INTERNAL_DECL duk_bool_t duk_hobject_enumerator_next(duk_context *ctx, duk_bool_t get_value)

◆ duk_put_global_string()

DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string ( duk_context * ctx,
const char * key )

Definition at line 14788 of file duktape-1.5.2/src-noline/duktape.c.

14790 {
14791 duk_hthread *thr = (duk_hthread *) ctx;
14792 duk_bool_t ret;
14793
14796
14797 /* XXX: direct implementation */
14798
14800 ret = duk_get_prop_string(ctx, -1, key);
14801 duk_remove(ctx, -2);
14802 return ret;
DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key)

◆ duk_put_number_list()

DUK_EXTERNAL_DECL void duk_put_number_list ( duk_context * ctx,
duk_idx_t obj_index,
const duk_number_list_entry * numbers )

Definition at line 14754 of file duktape-1.5.2/src-noline/duktape.c.

14756 {
14757 const duk_function_list_entry *ent = funcs;
14758
14760
14761 obj_index = duk_require_normalize_index(ctx, obj_index);
14762 if (ent != NULL) {
14763 while (ent->key != NULL) {
14764 duk_push_c_function(ctx, ent->value, ent->nargs);
14765 duk_put_prop_string(ctx, obj_index, ent->key);
14766 ent++;
14767 }
DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_int_t nargs)
static const luaL_Reg funcs[]
duk_idx_t nargs
duk_c_function value
const char * key

◆ duk_put_prop()

DUK_EXTERNAL_DECL duk_bool_t duk_put_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14378 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_put_prop_index()

DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14396 of file duktape-1.5.2/src-noline/duktape.c.

14400 {
14402 DUK_ASSERT(key != NULL);

◆ duk_put_prop_string()

DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14383 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_put_var()

DUK_EXTERNAL_DECL void duk_put_var ( duk_context * ctx)

Definition at line 19902 of file duktape-1.5.2/src-noline/duktape.c.

19919 {
19920 duk_hthread *thr = (duk_hthread *) ctx;
19921 duk_activation *act;
19922 duk_hstring *h_varname;
19923 duk_tval *tv_val;
19924 duk_small_int_t throw_flag;
19925
19927
19928 h_varname = duk_require_hstring(ctx, -2); /* XXX: tostring? */
19929 DUK_ASSERT(h_varname != NULL);
19930
19931 tv_val = duk_require_tval(ctx, -1);
19932
19933 throw_flag = duk_is_strict_call(ctx);
19934

◆ duk_realloc()

DUK_EXTERNAL_DECL void * duk_realloc ( duk_context * ctx,
void * ptr,
duk_size_t size )

Definition at line 14207 of file duktape-1.5.2/src-noline/duktape.c.

14208 {
14209 duk_hthread *thr = (duk_hthread *) ctx;
14210
14212
14213 return DUK_ALLOC(thr->heap, size);
14214}
14215
14216DUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr) {
14217 duk_hthread *thr = (duk_hthread *) ctx;
14218
14220
14221 DUK_FREE(thr->heap, ptr);
14222}
14223
#define DUK_ALLOC(heap, size)
#define DUK_FREE(heap, ptr)
DUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr)

◆ duk_realloc_raw()

DUK_EXTERNAL_DECL void * duk_realloc_raw ( duk_context * ctx,
void * ptr,
duk_size_t size )

Definition at line 14183 of file duktape-1.5.2/src-noline/duktape.c.

14184 {
14185 duk_hthread *thr = (duk_hthread *) ctx;
14186
14188
14189 return DUK_ALLOC_RAW(thr->heap, size);
#define DUK_ALLOC_RAW(heap, size)

◆ duk_remove()

DUK_EXTERNAL_DECL void duk_remove ( duk_context * ctx,
duk_idx_t index )

Definition at line 15820 of file duktape-1.5.2/src-noline/duktape.c.

15820 {
15821 duk_hthread *thr = (duk_hthread *) ctx;
15822 duk_tval *tv1;
15823 duk_tval *tv2;
15824
15826 DUK_UNREF(thr); /* w/o refcounting */
15827
15828 tv1 = duk_require_tval(ctx, from_index);
15829 DUK_ASSERT(tv1 != NULL);
15830 tv2 = duk_require_tval(ctx, to_index);
15831 DUK_ASSERT(tv2 != NULL);
15832
15833 /* For tv1 == tv2, this is a no-op (no explicit check needed). */
15834 DUK_TVAL_SET_TVAL_UPDREF(thr, tv2, tv1); /* side effects */
15835}
15836
15838 duk_hthread *thr = (duk_hthread *) ctx;
15839 duk_tval *p;
15840 duk_tval *q;
15841#ifdef DUK_USE_REFERENCE_COUNTING
15842 duk_tval tv_tmp;
15843#endif
15844 duk_size_t nbytes;
15845
15847
15848 p = duk_require_tval(ctx, index);
15849 DUK_ASSERT(p != NULL);
15850 q = duk_require_tval(ctx, -1);
15851 DUK_ASSERT(q != NULL);
15852
15853 DUK_ASSERT(q >= p);
15854
15855 /* nbytes zero size case
15856 * <--------->
15857 * [ ... | p | x | x | q ] [ ... | p==q ]
15858 * => [ ... | x | x | q ] [ ... ]
#define DUK_TVAL_SET_TVAL_UPDREF

◆ duk_replace()

DUK_EXTERNAL_DECL void duk_replace ( duk_context * ctx,
duk_idx_t to_index )

Definition at line 15780 of file duktape-1.5.2/src-noline/duktape.c.

15780 : to_index=%ld, p=%p, q=%p, nbytes=%lu",
15781 (long) to_index, (void *) p, (void *) q, (unsigned long) nbytes));
15782
15783 /* No net refcount changes. */
15784
15785 if (nbytes > 0) {
15786 DUK_TVAL_SET_TVAL(&tv_tmp, q);
15787 DUK_ASSERT(nbytes > 0);
15788 DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes);
15789 DUK_TVAL_SET_TVAL(p, &tv_tmp);
15790 } else {
15791 /* nop: insert top to top */
15792 DUK_ASSERT(nbytes == 0);
15793 DUK_ASSERT(p == q);
15794 }
15795}
15796
15797DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index) {
15798 duk_hthread *thr = (duk_hthread *) ctx;
15799 duk_tval *tv1;
15800 duk_tval *tv2;
15801 duk_tval tv_tmp;

◆ duk_require_boolean()

DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 15980 of file duktape-1.5.2/src-noline/duktape.c.

15982 {
15983 duk_bool_t ret = 0; /* default: false */
15984 duk_tval *tv;
15985
15987
15988 tv = duk_get_tval(ctx, index);
15989 if (tv && DUK_TVAL_IS_BOOLEAN(tv)) {
15990 ret = DUK_TVAL_GET_BOOLEAN(tv);
15991 }
15992
15993 DUK_ASSERT(ret == 0 || ret == 1);
15994 return ret;

◆ duk_require_buffer()

DUK_EXTERNAL_DECL void * duk_require_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16201 of file duktape-1.5.2/src-noline/duktape.c.

16202 {
16203 *out_size = DUK_HBUFFER_GET_SIZE(h);

◆ duk_require_buffer_data()

DUK_EXTERNAL_DECL void * duk_require_buffer_data ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16263 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_require_c_function()

DUK_EXTERNAL_DECL duk_c_function duk_require_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16404 of file duktape-1.5.2/src-noline/duktape.c.

16406 {
16407 return NULL;
16408 }
16409 h = DUK_TVAL_GET_OBJECT(tv);
16410 DUK_ASSERT(h != NULL);
16411
16413 return NULL;
16414 }
#define DUK_HOBJECT_HAS_NATIVEFUNCTION(h)

◆ duk_require_context()

DUK_EXTERNAL_DECL duk_context * duk_require_context ( duk_context * ctx,
duk_idx_t index )

Definition at line 16429 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_require_function()

DUK_EXTERNAL_DECL void duk_require_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16417 of file duktape-1.5.2/src-noline/duktape.c.

16421 {

◆ duk_require_heapptr()

DUK_EXTERNAL_DECL void * duk_require_heapptr ( duk_context * ctx,
duk_idx_t index )

Definition at line 16451 of file duktape-1.5.2/src-noline/duktape.c.

16452 {
16453 duk_tval *tv;
16454 void *ret;
16455
16457
16458 tv = duk_get_tval(ctx, index);
16459 if (tv && DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {
16460 ret = (void *) DUK_TVAL_GET_HEAPHDR(tv);
16461 DUK_ASSERT(ret != NULL);
16462 return ret;
16463 }
16464
16465 return (void *) NULL;
16466}
16467
DUK_EXTERNAL void * duk_require_heapptr(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)
#define DUK_TVAL_GET_HEAPHDR(tv)

◆ duk_require_int()

DUK_EXTERNAL_DECL duk_int_t duk_require_int ( duk_context * ctx,
duk_idx_t index )

Definition at line 16052 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_require_lstring()

DUK_EXTERNAL_DECL const char * duk_require_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16092 of file duktape-1.5.2/src-noline/duktape.c.

16094 {
16095 /* Here we rely on duk_hstring instances always being zero
16096 * terminated even if the actual string is not.
16097 */
16099 DUK_ASSERT(h != NULL);
16100 ret = (const char *) DUK_HSTRING_GET_DATA(h);
16101 if (out_len) {
16102 *out_len = DUK_HSTRING_GET_BYTELEN(h);
16103 }
16104 }
16105
16106 return ret;
16107}

◆ duk_require_normalize_index()

DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15092 of file duktape-1.5.2/src-noline/duktape.c.

15092 {
15093 uindex = vs_size + (duk_uidx_t) index;
15094 } else {
15095 /* since index non-negative */
15097 uindex = (duk_uidx_t) index;
15098 }
15099
15100 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15101 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15102
15103 if (DUK_LIKELY(uindex < vs_size)) {
15104 return (duk_idx_t) uindex;
15105 }
15106 return DUK_INVALID_INDEX;
15107}
15108
15110 duk_hthread *thr = (duk_hthread *) ctx;
15111 duk_uidx_t vs_size;
15112 duk_uidx_t uindex;
15113
15116
15118 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15119 DUK_ASSERT_DISABLE(vs_size >= 0); /* unsigned */

◆ duk_require_null()

DUK_EXTERNAL_DECL void duk_require_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 15951 of file duktape-1.5.2/src-noline/duktape.c.

15954 {
15955 duk_hthread *thr = (duk_hthread *) ctx;
15956 duk_tval *tv;
15957
15959
15960 tv = duk_get_tval(ctx, index);
15961 if (tv && DUK_TVAL_IS_UNDEFINED(tv)) {
15962 return;
15963 }
#define DUK_TVAL_IS_UNDEFINED(tv)

◆ duk_require_number()

DUK_EXTERNAL_DECL duk_double_t duk_require_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 16017 of file duktape-1.5.2/src-noline/duktape.c.

16021 {
16022 ret.d = DUK_TVAL_GET_NUMBER(tv);
16023 }
16024
16025 /*
16026 * Number should already be in NaN-normalized form, but let's
16027 * normalize anyway.
16028 */
16029
16031 return ret.d;
16032}
16033
16035 duk_hthread *thr = (duk_hthread *) ctx;
16036 duk_tval *tv;
16037
DUK_EXTERNAL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index)

◆ duk_require_pointer()

DUK_EXTERNAL_DECL void * duk_require_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 16135 of file duktape-1.5.2/src-noline/duktape.c.

16138 {
16139 duk_tval *tv;
16140
16142
16143 tv = duk_get_tval(ctx, index);
16144 if (tv && DUK_TVAL_IS_POINTER(tv)) {
16145 void *p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */
16146 return (void *) p;
16147 }
16148
16149 return NULL;
16150}
16151
#define DUK_TVAL_IS_POINTER(tv)
#define DUK_TVAL_GET_POINTER(tv)

◆ duk_require_stack()

DUK_EXTERNAL_DECL void duk_require_stack ( duk_context * ctx,
duk_idx_t extra )

Definition at line 15612 of file duktape-1.5.2/src-noline/duktape.c.

15614 {
15615 /* Clamping to zero makes the API more robust to calling code
15616 * calculation errors.
15617 */
15618 extra = 0;
15619 }
15620
15621 min_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;
15622 return duk_valstack_resize_raw(ctx,
15623 min_new_size, /* min_new_size */
15624 0 /* no shrink */ | /* flags */
15625 0 /* no compact */ |
15626 0 /* no throw */);
15627}
15628
15630 duk_hthread *thr = (duk_hthread *) ctx;
15631 duk_size_t min_new_size;
15632
DUK_EXTERNAL void duk_require_stack(duk_context *ctx, duk_idx_t extra)

◆ duk_require_stack_top()

DUK_EXTERNAL_DECL void duk_require_stack_top ( duk_context * ctx,
duk_idx_t top )

Definition at line 15654 of file duktape-1.5.2/src-noline/duktape.c.

15656 {
15657 /* Clamping to zero makes the API more robust to calling code
15658 * calculation errors.
15659 */
15660 top = 0;
15661 }
15662
15663 min_new_size = top + DUK_VALSTACK_INTERNAL_EXTRA;
15664 return duk_valstack_resize_raw(ctx,
15665 min_new_size, /* min_new_size */
15666 0 /* no shrink */ | /* flags */
15667 0 /* no compact */ |
15668 0 /* no throw */);
15669}
15670
15672 duk_size_t min_new_size;
DUK_EXTERNAL void duk_require_stack_top(duk_context *ctx, duk_idx_t top)

◆ duk_require_string()

DUK_EXTERNAL_DECL const char * duk_require_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 16115 of file duktape-1.5.2/src-noline/duktape.c.

16119 {

◆ duk_require_top_index()

DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index ( duk_context * ctx)

Definition at line 15324 of file duktape-1.5.2/src-noline/duktape.c.

15324 {
15325 duk_hthread *thr = (duk_hthread *) ctx;
15326 duk_idx_t ret;
15327
15329
15330 ret = ((duk_idx_t) (thr->valstack_top - thr->valstack_bottom)) - 1;
15331 if (DUK_UNLIKELY(ret < 0)) {
15332 /* Return invalid index; if caller uses this without checking
15333 * in another API call, the index won't map to a valid stack
15334 * entry.
15335 */
15336 return DUK_INVALID_INDEX;

◆ duk_require_uint()

DUK_EXTERNAL_DECL duk_uint_t duk_require_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16058 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_require_undefined()

DUK_EXTERNAL_DECL void duk_require_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 15937 of file duktape-1.5.2/src-noline/duktape.c.

15942 {
15943 p--;
15945 /* XXX: fast primitive to set a bunch of values to UNDEFINED */
15946 }
15947 }
15948}
15949

◆ duk_require_valid_index()

DUK_EXTERNAL_DECL void duk_require_valid_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15188 of file duktape-1.5.2/src-noline/duktape.c.

15189 {
15190 return thr->valstack_bottom + uindex;
15191 }
15193 return NULL;
15194}
15195
15196/* Non-critical. */
DUK_EXTERNAL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index)

◆ duk_resize_buffer()

DUK_EXTERNAL_DECL void * duk_resize_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t new_size )

Definition at line 11531 of file duktape-1.5.2/src-noline/duktape.c.

11531 : %p %lu -> %p",
11532 (void *) ptr, (unsigned long) newsize, (void *) res));
11533 return res;
11534}
11535
11536DUK_INTERNAL void duk_default_free_function(void *udata, void *ptr) {
11537 DUK_DDD(DUK_DDDPRINT("default free function: %p", (void *) ptr));
11538 DUK_UNREF(udata);
11539 DUK_ANSI_FREE(ptr);
11540}
11541#endif /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */
11542/*
11543 * Buffer
11544 */
11545
11546/* include removed: duk_internal.h */
11547
11548DUK_EXTERNAL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size) {
#define free
Definition civetweb.c:1542

◆ duk_safe_call()

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 )

Definition at line 12528 of file duktape-1.5.2/src-noline/duktape.c.

12545 {
12546 duk_hthread *thr = (duk_hthread *) ctx;
12547 duk_int_t rc;

◆ duk_safe_to_lstring()

DUK_EXTERNAL_DECL const char * duk_safe_to_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16929 of file duktape-1.5.2/src-noline/duktape.c.

16932 {
16934
16935 (void) duk_to_string(ctx, index);
16936 return duk_require_lstring(ctx, index, out_len);
16937}
16938
16941
16942 duk_to_string(ctx, -1);
16943 return 1;
16944}
16945
16948
16950
16951 /* We intentionally ignore the duk_safe_call() return value and only
16952 * check the output type. This way we don't also need to check that
16953 * the returned value is indeed a string in the success case.
16954 */
16955
16956 duk_dup(ctx, index);
16957 (void) duk_safe_call(ctx, duk__safe_to_string_raw, 1 /*nargs*/, 1 /*nrets*/);
16958 if (!duk_is_string(ctx, -1)) {
16959 /* Error: try coercing error to string once. */
DUK_EXTERNAL const char * duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t nargs, duk_idx_t nrets)
DUK_EXTERNAL const char * duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_ret_t duk__safe_to_string_raw(duk_context *ctx)

◆ duk_set_finalizer()

DUK_EXTERNAL_DECL void duk_set_finalizer ( duk_context * ctx,
duk_idx_t index )

Definition at line 14869 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_set_global_object()

DUK_EXTERNAL_DECL void duk_set_global_object ( duk_context * ctx)

Definition at line 14047 of file duktape-1.5.2/src-noline/duktape.c.

14050 {
14051 duk_hthread *thr = (duk_hthread *) ctx;
14052 duk_heap *heap;
14053
14054 if (!ctx) {
14055 return;
14056 }
14057 heap = thr->heap;
14058 DUK_ASSERT(heap != NULL);
14059
14060 duk_heap_free(heap);
14061}
14062
14063/* XXX: better place for this */
14065 duk_hthread *thr = (duk_hthread *) ctx;
14066 duk_hobject *h_glob;
14067 duk_hobject *h_prev_glob;
14068 duk_hobject *h_env;
14069 duk_hobject *h_prev_env;
14070
14071 DUK_D(DUK_DPRINT("replace global object with: %!T", duk_get_tval(ctx, -1)));
14072
14073 h_glob = duk_require_hobject(ctx, -1);
14074 DUK_ASSERT(h_glob != NULL);
14075
14076 /*
14077 * Replace global object.
14078 */
14079
14080 h_prev_glob = thr->builtins[DUK_BIDX_GLOBAL];
14081 DUK_UNREF(h_prev_glob);
14082 thr->builtins[DUK_BIDX_GLOBAL] = h_glob;
14083 DUK_HOBJECT_INCREF(thr, h_glob);
14084 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_glob); /* side effects, in theory (referenced by global env) */
14085
14086 /*
14087 * Replace lexical environment for global scope
14088 *
14089 * Create a new object environment for the global lexical scope.
14090 * We can't just reset the _Target property of the current one,
14091 * because the lexical scope is shared by other threads with the
14092 * same (initial) built-ins.
14093 */
14094
14095 (void) duk_push_object_helper(ctx,
14098 -1); /* no prototype, updated below */
14099
14100 duk_dup(ctx, -2);
14101 duk_dup(ctx, -3);
14102
14103 /* [ ... new_glob new_env new_glob new_glob ] */
14104
14107
14108 /* [ ... new_glob new_env ] */
DUK_INTERNAL_DECL void duk_heap_free(duk_heap *heap)
#define DUK_HOBJECT_DECREF_ALLOWNULL(thr, h)
#define DUK_PROPDESC_FLAGS_NONE
#define DUK_HOBJECT_CLASS_OBJENV
DUK_EXTERNAL void duk_set_global_object(duk_context *ctx)
#define DUK_HOBJECT_INCREF(thr, h)

◆ duk_set_magic()

DUK_EXTERNAL_DECL void duk_set_magic ( duk_context * ctx,
duk_idx_t index,
duk_int_t magic )

Definition at line 12871 of file duktape-1.5.2/src-noline/duktape.c.

12873 {
12874 goto type_error;
12875 }
12876 return (duk_int_t) ((duk_hnativefunction *) h)->magic;
12877 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
12879 return (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);

◆ duk_set_prototype()

DUK_EXTERNAL_DECL void duk_set_prototype ( duk_context * ctx,
duk_idx_t index )

Definition at line 14828 of file duktape-1.5.2/src-noline/duktape.c.

14838 {
14839 duk_push_hobject(ctx, proto);
14840 } else {
14841 duk_push_undefined(ctx);
14842 }
14843}
14844
14846 duk_hthread *thr = (duk_hthread *) ctx;
14847 duk_hobject *obj;
14849
14851
14852 obj = duk_require_hobject(ctx, index);
DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t index)

◆ duk_set_top()

DUK_EXTERNAL_DECL void duk_set_top ( duk_context * ctx,
duk_idx_t index )

Definition at line 15216 of file duktape-1.5.2/src-noline/duktape.c.

15221 {
15222 duk_hthread *thr = (duk_hthread *) ctx;
15223
15225
15226 return (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
15227}
15228
15229/* Set stack top within currently allocated range, but don't reallocate.
15230 * This is performance critical especially for call handling, so whenever
15231 * changing, profile and look at generated code.
15232 */
15234 duk_hthread *thr = (duk_hthread *) ctx;
15235 duk_uidx_t vs_size;
15236 duk_uidx_t vs_limit;
15237 duk_uidx_t uindex;
15238 duk_tval *tv;
15239
15242
15245 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15246 vs_limit = (duk_uidx_t) (thr->valstack_end - thr->valstack_bottom);
15247
15248 if (index < 0) {
15249 /* Negative indices are always within allocated stack but
15250 * must not go below zero index.
15251 */
15252 uindex = vs_size + (duk_uidx_t) index;
15253 } else {
15254 /* Positive index can be higher than valstack top but must
15255 * not go above allocated stack (equality is OK).
15256 */
15257 uindex = (duk_uidx_t) index;
15258 }
15259
15260 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15261 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15262 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_limit);
15263
15264#if defined(DUK_USE_VALSTACK_UNSAFE)
15265 DUK_ASSERT(uindex <= vs_limit);
15266 DUK_UNREF(vs_limit);
15267#else
15268 if (DUK_UNLIKELY(uindex > vs_limit)) {
15270 return; /* unreachable */
15271 }
15272#endif
15273 DUK_ASSERT(uindex <= vs_limit);
15274
15275 /* Handle change in value stack top. Respect value stack
15276 * initialization policy: 'undefined' above top. Note that
15277 * DECREF may cause a side effect that reallocates valstack,
15278 * so must relookup after DECREF.
15279 */
15280
15281 if (uindex >= vs_size) {
15282 /* Stack size increases or stays the same. */
15283#if defined(DUK_USE_ASSERTIONS)
15284 duk_uidx_t count;
15285
15286 count = uindex - vs_size;
15287 while (count != 0) {
15288 count--;
15289 tv = thr->valstack_top + count;
15291 }
15292#endif
15293 thr->valstack_top = thr->valstack_bottom + uindex;
15294 } else {
15295 /* Stack size decreases. */
15296#if defined(DUK_USE_REFERENCE_COUNTING)
15297 duk_uidx_t count;
15298
15299 count = vs_size - uindex;
15300 DUK_ASSERT(count > 0);
15301 while (count > 0) {
15302 count--;
15303 tv = --thr->valstack_top; /* tv -> value just before prev top value; must relookup */
15304 DUK_ASSERT(tv >= thr->valstack_bottom);
15305 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv); /* side effects */
DUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_SET_UNDEFINED_UPDREF

◆ duk_steal_buffer()

DUK_EXTERNAL_DECL void * duk_steal_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 11550 of file duktape-1.5.2/src-noline/duktape.c.

11557 {
11559 }
11560
11561 /* maximum size check is handled by callee */
11562 duk_hbuffer_resize(thr, h, new_size);
11563
11564 return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);
11565}
11566
11568 duk_hthread *thr = (duk_hthread *) ctx;
11570 void *ptr;
11571 duk_size_t sz;
11572
11573 DUK_ASSERT(ctx != NULL);
11574
11576 DUK_ASSERT(h != NULL);
11577
#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, x)
DUK_INTERNAL_DECL void duk_hbuffer_resize(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_size_t new_size)
DUK_EXTERNAL void * duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
#define DUK_STR_WRONG_BUFFER_TYPE

◆ duk_strict_equals()

DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19300 of file duktape-1.5.2/src-noline/duktape.c.

19307 {
19308 return 0;
19309 }
19310
19311 /* Coercion may be needed, the helper handles that by pushing the
19312 * tagged values to the stack.
19313 */

◆ duk_substring()

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 )

Definition at line 19721 of file duktape-1.5.2/src-noline/duktape.c.

19724 {
19725 break;
19726 }
19727 cp = (int) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
19728 cp = callback(udata, cp);
19729
19730 DUK_BW_WRITE_ENSURE_XUTF8(thr, bw, cp);
19731 }
19732
19733 DUK_BW_COMPACT(thr, bw);
19734 duk_to_string(ctx, -1);
19735 duk_replace(ctx, index);
19736}
19737
19738DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset) {
19739 duk_hthread *thr = (duk_hthread *) ctx;
19740 duk_hstring *h;
19741 duk_hstring *res;
19742 duk_size_t start_byte_offset;
19743 duk_size_t end_byte_offset;
19744
19746
19748 h = duk_require_hstring(ctx, index);
19749 DUK_ASSERT(h != NULL);
19750
19751 if (end_offset >= DUK_HSTRING_GET_CHARLEN(h)) {
19752 end_offset = DUK_HSTRING_GET_CHARLEN(h);
19753 }
19754 if (start_offset > end_offset) {
19755 start_offset = end_offset;
19756 }
19757
19758 DUK_ASSERT_DISABLE(start_offset >= 0);
19759 DUK_ASSERT(start_offset <= end_offset && start_offset <= DUK_HSTRING_GET_CHARLEN(h));
19760 DUK_ASSERT_DISABLE(end_offset >= 0);
19761 DUK_ASSERT(end_offset >= start_offset && end_offset <= DUK_HSTRING_GET_CHARLEN(h));
19762
19763 /* guaranteed by string limits */
#define DUK_BW_COMPACT(thr, bw_ctx)
DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset)
#define DUK_BW_WRITE_ENSURE_XUTF8(thr, bw_ctx, cp)

◆ duk_swap()

DUK_EXTERNAL_DECL void duk_swap ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 15678 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_swap_top()

DUK_EXTERNAL_DECL void duk_swap_top ( duk_context * ctx,
duk_idx_t index )

Definition at line 15696 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_to_boolean()

DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 16744 of file duktape-1.5.2/src-noline/duktape.c.

16746 {
16748 DUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING);
16749
16751
16754 /* everything except object stay as is */
16755 return;
16756 }
16757 duk_to_defaultvalue(ctx, index, hint);
16758}
16759
16760/* E5 Section 9.2 */
16762 duk_hthread *thr = (duk_hthread *) ctx;
16763 duk_tval *tv;
16764 duk_bool_t val;
DUK_EXTERNAL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask)
DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint)

◆ duk_to_buffer_raw()

DUK_EXTERNAL_DECL void * duk_to_buffer_raw ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size,
duk_uint_t flags )

Definition at line 17186 of file duktape-1.5.2/src-noline/duktape.c.

17190 :
17191 return duk_require_string(ctx, index);
17192}
17193
17195 duk_hstring *ret;
17197 duk_to_string(ctx, index);
17198 ret = duk_get_hstring(ctx, index);
17199 DUK_ASSERT(ret != NULL);
17200 return ret;
17201}
17202
17204 duk_hthread *thr = (duk_hthread *) ctx;
17205 duk_hbuffer *h_buf;
17206 const duk_uint8_t *src_data;
17207 duk_size_t src_size;
17208 duk_uint8_t *dst_data;
17209
17211 DUK_UNREF(thr);
17212
17214
17215 h_buf = duk_get_hbuffer(ctx, index);
17216 if (h_buf != NULL) {
17217 /* Buffer is kept as is, with the fixed/dynamic nature of the
17218 * buffer only changed if requested. An external buffer
17219 * is converted into a non-external dynamic buffer in a
17220 * duk_to_dynamic_buffer() call.
17221 */
17222 duk_uint_t tmp;
17223 duk_uint8_t *tmp_ptr;
17224
17225 tmp_ptr = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_buf);
17226 src_data = (const duk_uint8_t *) tmp_ptr;
17227 src_size = DUK_HBUFFER_GET_SIZE(h_buf);
17228
17230 if ((tmp == mode && !DUK_HBUFFER_HAS_EXTERNAL(h_buf)) ||
17231 mode == DUK_BUF_MODE_DONTCARE) {
17232 /* Note: src_data may be NULL if input is a zero-size
17233 * dynamic buffer.
17234 */
17235 dst_data = tmp_ptr;
17236 goto skip_copy;
17237 }
17238 } else {
17239 /* Non-buffer value is first ToString() coerced, then converted
17240 * to a buffer (fixed buffer is used unless a dynamic buffer is
17241 * explicitly requested).
17242 */
17243
17244 src_data = (const duk_uint8_t *) duk_to_lstring(ctx, index, &src_size);
17245 }
17246
DUK_INTERNAL_DECL duk_hstring * duk_to_hstring(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL const char * duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_INTERNAL_DECL duk_hbuffer * duk_get_hbuffer(duk_context *ctx, duk_idx_t index)
#define DUK_HBUFFER_GET_DATA_PTR(heap, x)
DUK_EXTERNAL void * duk_to_buffer_raw(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t mode)
DUK_INTERNAL_DECL duk_hstring * duk_get_hstring(duk_context *ctx, duk_idx_t index)
#define DUK_BUF_MODE_DONTCARE
#define DUK_BUF_MODE_DYNAMIC

◆ duk_to_defaultvalue()

DUK_EXTERNAL_DECL void duk_to_defaultvalue ( duk_context * ctx,
duk_idx_t index,
duk_int_t hint )

Definition at line 16665 of file duktape-1.5.2/src-noline/duktape.c.

16665 {
16666 if (duk_get_prop_stridx(ctx, index, func_stridx)) {
16667 /* [ ... func ] */
16668 if (duk_is_callable(ctx, -1)) {
16669 duk_dup(ctx, index); /* -> [ ... func this ] */
16670 duk_call_method(ctx, 0); /* -> [ ... retval ] */
16671 if (duk_is_primitive(ctx, -1)) {
16672 duk_replace(ctx, index);
16673 return 1;
16674 }
16675 /* [ ... retval ]; popped below */
16676 }
16677 }
16678 duk_pop(ctx); /* [ ... func/retval ] -> [ ... ] */
16679 return 0;
16680}
16681
16683 duk_hthread *thr = (duk_hthread *) ctx;
16684 duk_hobject *obj;
16685 /* inline initializer for coercers[] is not allowed by old compilers like BCC */
16686 duk_small_int_t coercers[2];
16687
16689 DUK_ASSERT(thr != NULL);
16690
16691 coercers[0] = DUK_STRIDX_VALUE_OF;
16692 coercers[1] = DUK_STRIDX_TO_STRING;
16693
16696
16697 if (hint == DUK_HINT_NONE) {
16699 hint = DUK_HINT_STRING;
16700 } else {
16701 hint = DUK_HINT_NUMBER;
16702 }
#define DUK_HOBJECT_CLASS_DATE
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t index)
#define DUK_STRIDX_VALUE_OF
#define duk_is_primitive(ctx, index)

◆ duk_to_int()

DUK_EXTERNAL_DECL duk_int_t duk_to_int ( duk_context * ctx,
duk_idx_t index )

Definition at line 16809 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_to_int32()

DUK_EXTERNAL_DECL duk_int32_t duk_to_int32 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16827 of file duktape-1.5.2/src-noline/duktape.c.

16835 {
16836 /* Value coercion (in stack): ToInteger(), E5 Section 9.4
16837 * API return value coercion: custom
16838 */
16841 return (duk_uint_t) duk__api_coerce_d2ui(ctx, index, 0 /*require*/);
16842}
DUK_LOCAL duk_double_t duk__to_int_uint_helper(duk_context *ctx, duk_idx_t index, duk__toint_coercer coerce_func)
DUK_INTERNAL_DECL duk_double_t duk_js_tointeger(duk_hthread *thr, duk_tval *tv)

◆ duk_to_lstring()

DUK_EXTERNAL_DECL const char * duk_to_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16915 of file duktape-1.5.2/src-noline/duktape.c.

16918 {
16919 /* Exact halfway, round to even. */
16920 ret = (duk_uint8_t) d;

◆ duk_to_null()

DUK_EXTERNAL_DECL void duk_to_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 16716 of file duktape-1.5.2/src-noline/duktape.c.

16721 {
16722 duk_hthread *thr = (duk_hthread *) ctx;
16723 duk_tval *tv;
16724
16726 DUK_UNREF(thr);

◆ duk_to_number()

DUK_EXTERNAL_DECL duk_double_t duk_to_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 16766 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_to_object()

DUK_EXTERNAL_DECL void duk_to_object ( duk_context * ctx,
duk_idx_t index )

Definition at line 17299 of file duktape-1.5.2/src-noline/duktape.c.

17301 :
17302#endif
17303 default:
17304 /* number */
17307 res = NULL;
17308 break;
17309 }
17310
17311 duk_push_pointer(ctx, res);
17312 duk_replace(ctx, index);
17313 return res;
17314}
17315
17317 duk_hthread *thr = (duk_hthread *) ctx;
17318 duk_tval *tv;
17319 duk_uint_t flags = 0; /* shared flags for a subset of types */
17321
17323
17325
17326 tv = duk_require_tval(ctx, index);
17327 DUK_ASSERT(tv != NULL);
17328
17329 switch (DUK_TVAL_GET_TAG(tv)) {
17330 case DUK_TAG_UNDEFINED:
17331 case DUK_TAG_NULL: {
17333 break;
17334 }
17335 case DUK_TAG_BOOLEAN: {
17339 goto create_object;
17340 }
17341 case DUK_TAG_STRING: {
17346 goto create_object;
17347 }
17348 case DUK_TAG_OBJECT: {
17349 /* nop */
17350 break;
17351 }
17352 case DUK_TAG_BUFFER: {
17353 /* A plain buffer coerces to a Duktape.Buffer because it's the
17354 * object counterpart of the plain buffer value. But it might
17355 * still make more sense to produce an ArrayBuffer here?
17356 */
17357
17358 duk_hbufferobject *h_bufobj;
17359 duk_hbuffer *h_val;
17360
17361 h_val = DUK_TVAL_GET_BUFFER(tv);
17362 DUK_ASSERT(h_val != NULL);
17363
17364 h_bufobj = duk_push_bufferobject_raw(ctx,
17369 DUK_ASSERT(h_bufobj != NULL);
17372
17373 h_bufobj->buf = h_val;
17374 DUK_HBUFFER_INCREF(thr, h_val);
17375 DUK_ASSERT(h_bufobj->offset == 0);
17376 h_bufobj->length = (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_val);
17377 DUK_ASSERT(h_bufobj->shift == 0);
17379
17381 goto replace_value;
17382 }
17383 case DUK_TAG_POINTER: {
17387 goto create_object;
17388 }
17389 case DUK_TAG_LIGHTFUNC: {
17390 /* Lightfunc coerces to a Function instance with concrete
17391 * properties. Since 'length' is virtual for Duktape/C
17392 * functions, don't need to define that.
17393 *
17394 * The result is made extensible to mimic what happens to
17395 * strings:
17396 * > Object.isExtensible(Object('foo'))
17397 * true
17398 */
17399 duk_small_uint_t lf_flags;
17400 duk_idx_t nargs;
17401 duk_small_uint_t lf_len;
17402 duk_c_function func;
17404
17405 DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);
17406
17407 nargs = (duk_idx_t) DUK_LFUNC_FLAGS_GET_NARGS(lf_flags);
17408 if (nargs == DUK_LFUNC_NARGS_VARARGS) {
17409 nargs = (duk_idx_t) DUK_VARARGS;
17410 }
17417 /* DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC: omitted here intentionally */
17419 (void) duk__push_c_function_raw(ctx, func, nargs, flags);
17420
17421 lf_len = DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);
17422 if ((duk_idx_t) lf_len != nargs) {
17423 /* Explicit length is only needed if it differs from 'nargs'. */
17424 duk_push_int(ctx, (duk_int_t) lf_len);
17426 }
17427 duk_push_lightfunc_name(ctx, tv);
17429
17430 nf = duk_get_hnativefunction(ctx, -1);
17431 DUK_ASSERT(nf != NULL);
17432 nf->magic = (duk_int16_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);
17433
17434 /* Enable DUKFUNC exotic behavior once properties are set up. */
17436 goto replace_value;
17437 }
17438#if defined(DUK_USE_FASTINT)
17439 case DUK_TAG_FASTINT:
17440#endif
17441 default: {
17447 goto create_object;
17448 }
17449 }
17450 return;
#define DUK_HOBJECT_CLASS_BOOLEAN
#define DUK_HOBJECT_FLAG_CONSTRUCTABLE
#define DUK_HOBJECT_CLASS_POINTER
DUK_INTERNAL_DECL void duk_push_lightfunc_name(duk_context *ctx, duk_tval *tv)
#define DUK_BIDX_POINTER_PROTOTYPE
#define DUK_BIDX_STRING_PROTOTYPE
DUK_INTERNAL_DECL duk_hnativefunction * duk_get_hnativefunction(duk_context *ctx, duk_idx_t index)
#define DUK_STR_NOT_OBJECT_COERCIBLE
#define DUK_HOBJECT_CLASS_NUMBER
#define DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ
#define DUK_HOBJECT_IS_BUFFEROBJECT(h)
#define DUK_BIDX_NUMBER_PROTOTYPE
#define DUK_BIDX_BOOLEAN_PROTOTYPE
#define DUK_TVAL_GET_LIGHTFUNC(tv, out_fp, out_flags)
DUK_EXTERNAL void duk_to_object(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_SET_EXOTIC_DUKFUNC(h)
#define DUK_LFUNC_FLAGS_GET_NARGS(lf_flags)
#define DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags)
#define DUK_HOBJECT_HAS_EXTENSIBLE(h)
#define DUK_HOBJECT_CLASS_STRING

◆ duk_to_pointer()

DUK_EXTERNAL_DECL void * duk_to_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17248 of file duktape-1.5.2/src-noline/duktape.c.

17248 {
17249 /* When src_size == 0, src_data may be NULL (if source
17250 * buffer is dynamic), and dst_data may be NULL (if
17251 * target buffer is dynamic). Avoid zero-size memcpy()
17252 * with an invalid pointer.
17253 */
17254 DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size);
17255 }
17256 duk_replace(ctx, index);
17257 skip_copy:
17258
17259 if (out_size) {
17260 *out_size = src_size;
17261 }
17262 return dst_data;
17263}
17264
17266 duk_tval *tv;
17267 void *res;
17268
17270
17272
17273 tv = duk_require_tval(ctx, index);
17274 DUK_ASSERT(tv != NULL);
17275
17276 switch (DUK_TVAL_GET_TAG(tv)) {
17277 case DUK_TAG_UNDEFINED:
17278 case DUK_TAG_NULL:
17279 case DUK_TAG_BOOLEAN:
17280 res = NULL;
17281 break;
17282 case DUK_TAG_POINTER:
17283 res = DUK_TVAL_GET_POINTER(tv);
17284 break;
17285 case DUK_TAG_STRING:
17286 case DUK_TAG_OBJECT:
17287 case DUK_TAG_BUFFER:
17288 /* Heap allocated: return heap pointer which is NOT useful
17289 * for the caller, except for debugging.
17290 */
17291 res = (void *) DUK_TVAL_GET_HEAPHDR(tv);
17292 break;
17293 case DUK_TAG_LIGHTFUNC:
17294 /* Function pointers do not always cast correctly to void *
17295 * (depends on memory and segmentation model for instance),
17296 * so they coerce to NULL.
17297 */
DUK_EXTERNAL void * duk_to_pointer(duk_context *ctx, duk_idx_t index)

◆ duk_to_primitive()

DUK_EXTERNAL_DECL void duk_to_primitive ( duk_context * ctx,
duk_idx_t index,
duk_int_t hint )

Definition at line 16729 of file duktape-1.5.2/src-noline/duktape.c.

16733 {
16734 duk_hthread *thr = (duk_hthread *) ctx;
16735 duk_tval *tv;
16736
16738 DUK_UNREF(thr);
16739
16740 tv = duk_require_tval(ctx, index);
16741 DUK_ASSERT(tv != NULL);

◆ duk_to_string()

DUK_EXTERNAL_DECL const char * duk_to_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 17089 of file duktape-1.5.2/src-noline/duktape.c.

17089 {
17091 }
17092 }
17093
17094 return res;
17095}
17096
17099 return duk_to_int_clamped_raw(ctx, index, minval, maxval, &dummy);
17100}
17101
17103 return duk_to_int_clamped_raw(ctx, index, minval, maxval, NULL); /* out_clamped==NULL -> RangeError if outside range */
17104}
17105
17107 duk_hthread *thr = (duk_hthread *) ctx;
17108 duk_tval *tv;
17109
17111 DUK_UNREF(thr);
17112
17114
17115 tv = duk_require_tval(ctx, index);
17116 DUK_ASSERT(tv != NULL);
17117
17118 switch (DUK_TVAL_GET_TAG(tv)) {
17119 case DUK_TAG_UNDEFINED: {
17121 break;
17122 }
17123 case DUK_TAG_NULL: {
17125 break;
17126 }
17127 case DUK_TAG_BOOLEAN: {
17128 if (DUK_TVAL_GET_BOOLEAN(tv)) {
17130 } else {
17132 }
17133 break;
17134 }
17135 case DUK_TAG_STRING: {
17136 /* nop */
17137 goto skip_replace;
17138 }
17139 case DUK_TAG_OBJECT: {
17141 return duk_to_string(ctx, index); /* Note: recursive call */
17142 }
17143 case DUK_TAG_BUFFER: {
17145
17146 /* Note: this allows creation of internal strings. */
17147
17148 DUK_ASSERT(h != NULL);
17149 duk_push_lstring(ctx,
17150 (const char *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h),
17152 break;
17153 }
17154 case DUK_TAG_POINTER: {
17155 void *ptr = DUK_TVAL_GET_POINTER(tv);
17156 if (ptr != NULL) {
17157 duk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) ptr);
17158 } else {
17159 /* Represent a null pointer as 'null' to be consistent with
17160 * the JX format variant. Native '%p' format for a NULL
17161 * pointer may be e.g. '(nil)'.
17162 */
17164 }
17165 break;
17166 }
17167 case DUK_TAG_LIGHTFUNC: {
17168 /* Should match Function.prototype.toString() */
17170 break;
17171 }
17172#if defined(DUK_USE_FASTINT)
17173 case DUK_TAG_FASTINT:
17174#endif
17175 default: {
#define DUK_STR_NUMBER_OUTSIDE_RANGE
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped)
DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
DUK_EXTERNAL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint)
DUK_INTERNAL_DECL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *tv)
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
#define DUK_STRIDX_LC_UNDEFINED
DUK_EXTERNAL const char * duk_push_sprintf(duk_context *ctx, const char *fmt,...)

◆ duk_to_uint()

DUK_EXTERNAL_DECL duk_uint_t duk_to_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16818 of file duktape-1.5.2/src-noline/duktape.c.

◆ duk_to_uint16()

DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16861 of file duktape-1.5.2/src-noline/duktape.c.

16861 {
16862 duk_hthread *thr = (duk_hthread *) ctx;
16863 duk_tval *tv;
16864 duk_uint32_t ret;
16865
16867
16868 tv = duk_require_tval(ctx, index);
16869 DUK_ASSERT(tv != NULL);
16870 ret = duk_js_touint32(thr, tv);
16871
16872 /* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */
16873 tv = duk_require_tval(ctx, index);
16874 DUK_TVAL_SET_FASTINT_U32_UPDREF(thr, tv, ret); /* side effects */
16875 return ret;
16876}
#define DUK_TVAL_SET_FASTINT_U32_UPDREF
DUK_INTERNAL_DECL duk_uint32_t duk_js_touint32(duk_hthread *thr, duk_tval *tv)

◆ duk_to_uint32()

DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16844 of file duktape-1.5.2/src-noline/duktape.c.

16844 {
16845 duk_hthread *thr = (duk_hthread *) ctx;
16846 duk_tval *tv;
16847 duk_int32_t ret;
16848
16850
16851 tv = duk_require_tval(ctx, index);
16852 DUK_ASSERT(tv != NULL);
16853 ret = duk_js_toint32(thr, tv);
16854
16855 /* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */
16856 tv = duk_require_tval(ctx, index);
16857 DUK_TVAL_SET_FASTINT_I32_UPDREF(thr, tv, ret); /* side effects */
16858 return ret;
16859}
DUK_INTERNAL_DECL duk_int32_t duk_js_toint32(duk_hthread *thr, duk_tval *tv)
#define DUK_TVAL_SET_FASTINT_I32_UPDREF

◆ duk_to_undefined()

DUK_EXTERNAL_DECL void duk_to_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 16704 of file duktape-1.5.2/src-noline/duktape.c.

16705 {
16706 coercers[0] = DUK_STRIDX_TO_STRING;
16707 coercers[1] = DUK_STRIDX_VALUE_OF;
16708 }
16709
16710 if (duk__defaultvalue_coerce_attempt(ctx, index, coercers[0])) {
16711 return;
16712 }
16713
16714 if (duk__defaultvalue_coerce_attempt(ctx, index, coercers[1])) {
DUK_LOCAL duk_bool_t duk__defaultvalue_coerce_attempt(duk_context *ctx, duk_idx_t index, duk_small_int_t func_stridx)

◆ duk_trim()

DUK_EXTERNAL_DECL void duk_trim ( duk_context * ctx,
duk_idx_t index )

Definition at line 19768 of file duktape-1.5.2/src-noline/duktape.c.

19785 {
19786 duk_hthread *thr = (duk_hthread *) ctx;
19787 duk_hstring *h;
19788 const duk_uint8_t *p, *p_start, *p_end, *p_tmp1, *p_tmp2; /* pointers for scanning */
19789 const duk_uint8_t *q_start, *q_end; /* start (incl) and end (excl) of trimmed part */
19790 duk_codepoint_t cp;
19791
19793
19795 h = duk_require_hstring(ctx, index);
19796 DUK_ASSERT(h != NULL);
19797
19798 p_start = DUK_HSTRING_GET_DATA(h);
19799 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h);
19800
19801 p = p_start;
19802 while (p < p_end) {
19803 p_tmp1 = p;
19804 cp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp1, p_start, p_end);
19806 break;
19807 }
19808 p = p_tmp1;
19809 }
19810 q_start = p;
19811 if (p == p_end) {
19812 /* entire string is whitespace */
19813 q_end = p;
19814 goto scan_done;
19815 }
19816
19817 p = p_end;
19818 while (p > p_start) {
19819 p_tmp1 = p;
19820 while (p > p_start) {
19821 p--;
19822 if (((*p) & 0xc0) != 0x80) {
19823 break;
19824 }
19825 }
19826 p_tmp2 = p;
19827
19828 cp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp2, p_start, p_end);
19830 p = p_tmp1;
19831 break;
19832 }
19833 }
19834 q_end = p;
19835
19836 scan_done:
19837 /* This may happen when forward and backward scanning disagree
19838 * (possible for non-extended-UTF-8 strings).
19839 */
19840 if (q_end < q_start) {
19841 q_end = q_start;
19842 }
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator(duk_codepoint_t cp)

◆ duk_xcopymove_raw()

DUK_EXTERNAL_DECL void duk_xcopymove_raw ( duk_context * to_ctx,
duk_context * from_ctx,
duk_idx_t count,
duk_bool_t is_copy )

Definition at line 15864 of file duktape-1.5.2/src-noline/duktape.c.

15881 {
15882 duk_hthread *to_thr = (duk_hthread *) to_ctx;
15883 duk_hthread *from_thr = (duk_hthread *) from_ctx;
15884 void *src;
15885 duk_size_t nbytes;
15886 duk_tval *p;
15887 duk_tval *q;
15888
15889 /* XXX: several pointer comparison issues here */
15890
15891 DUK_ASSERT_CTX_VALID(to_ctx);
15892 DUK_ASSERT_CTX_VALID(from_ctx);
15893 DUK_ASSERT(to_ctx != NULL);
15894 DUK_ASSERT(from_ctx != NULL);
15895
15896 if (to_ctx == from_ctx) {
15898 return;
15899 }
15900 if ((count < 0) ||
15901 (count > (duk_idx_t) to_thr->valstack_max)) {
15902 /* Maximum value check ensures 'nbytes' won't wrap below. */
15904 return;
15905 }
15906
15907 nbytes = sizeof(duk_tval) * count;
15908 if (nbytes == 0) {
15909 return;
15910 }
15911 DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end);
15912 if ((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes) {
15914 }
15915 src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes);
15916 if (src < (void *) from_thr->valstack_bottom) {
15918 }
15919
15920 /* copy values (no overlap even if to_ctx == from_ctx; that's not
15921 * allowed now anyway)
15922 */
15923 DUK_ASSERT(nbytes > 0);
15924 DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes);
15925
15926 p = to_thr->valstack_top;
15927 to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes);
15928
15929 if (is_copy) {
15930 /* Incref copies, keep originals. */
15931 q = to_thr->valstack_top;
struct duk_tval_struct duk_tval
#define DUK_STR_INVALID_CONTEXT

Variable Documentation

◆ duk_api_global_filename

DUK_EXTERNAL_DECL const char* duk_api_global_filename

Definition at line 382 of file duktape-1.5.2/src-noline/duktape.h.

◆ duk_api_global_line

DUK_EXTERNAL_DECL duk_int_t duk_api_global_line

Definition at line 383 of file duktape-1.5.2/src-noline/duktape.h.