1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

1. Updated to duktape 2.6.0

2. Added support for execution timeout
This commit is contained in:
Bryan Roe
2021-02-16 15:10:28 -08:00
parent 9d2fe9b2b0
commit 71b5e588c3
8 changed files with 11670 additions and 8367 deletions

View File

@@ -1486,7 +1486,9 @@ duk_ret_t ILibDuktape_MeshAgent_eval(duk_context *ctx)
char *evalStr = (char*)duk_get_lstring(ctx, 0, &evalStrLen);
printf("eval(): %s\n", evalStr);
ILibDuktape_ExecutorTimeout_Start(ctx);
duk_eval_string(ctx, evalStr);
ILibDuktape_ExecutorTimeout_Stop(ctx);
return(1);
}
duk_context* ScriptEngine_Stop(MeshAgentHostContainer *agent, char *contextGUID);
@@ -1512,8 +1514,8 @@ void ILibDuktape_MeshAgent_dumpCoreModuleEx(void *chain, void *user)
{
ILibRemoteLogging_printf(ILibChainGetLogger(agentHost->chain), ILibRemoteLogging_Modules_Microstack_Generic | ILibRemoteLogging_Modules_ConsolePrint,
ILibRemoteLogging_Flags_VerbosityLevel_1, "Error Executing MeshCore: %s", duk_safe_to_string(agentHost->meshCoreCtx, -1));
duk_pop(agentHost->meshCoreCtx);
}
duk_pop(agentHost->meshCoreCtx);
free(CoreModule);
}
}
@@ -3986,7 +3988,7 @@ void MeshServer_Agent_SelfTest(MeshAgentHostContainer *agent)
if (duk_peval_string(agent->meshCoreCtx, "require('agent-selftest')();") != 0)
{
printf(" -> Loading Test Script.................[FAILED]\n");
printf(" -> Loading Test Script.................[FAILED] %s", duk_safe_to_string(agent->meshCoreCtx, -1));
exit(1);
}
duk_pop(agent->meshCoreCtx);

View File

@@ -51,6 +51,29 @@ typedef struct Duktape_EventLoopDispatchData
void *user;
}Duktape_EventLoopDispatchData;
duk_bool_t ILibDuktape_EXEC_TIMEOUT_CHECK(void *udata)
{
ILibDuktape_ContextData *ctxd = (ILibDuktape_ContextData*)udata;
if (ctxd->executionTime == 0 || ctxd->maxExecutionTime == 0) { return(0); }
if ((ILibGetUptime() - ctxd->executionTime) > ctxd->maxExecutionTime)
{
ctxd->executionTime = 0;
ctxd->executionCount = 0;
return(1);
}
return(0);
}
void ILibDuktape_ExecutorTimeout_Start(duk_context *ctx)
{
ILibDuktape_ContextData *ctxd = (ILibDuktape_ContextData*)duk_ctx_context_data(ctx);
if (ctxd != NULL && ctxd->executionCount++ == 0) { ctxd->executionTime = ILibGetUptime(); }
}
void ILibDuktape_ExecutorTimeout_Stop(duk_context *ctx)
{
ILibDuktape_ContextData *ctxd = (ILibDuktape_ContextData*)duk_ctx_context_data(ctx);
if (ctxd != NULL && --ctxd->executionCount <= 0) { ctxd->executionTime = 0; ctxd->executionCount = 0; }
}
duk_ret_t duk_fixed_buffer_finalizer(duk_context *ctx)
{

View File

@@ -54,12 +54,16 @@ typedef struct ILibDuktape_ContextData
#ifdef WIN32
uint32_t apc_flags;
#endif
uint32_t executionCount;
uint64_t executionTime;
uint32_t maxExecutionTime;
void *threads;
int fakechain;
void *chain;
void *user;
}ILibDuktape_ContextData;
#define DUKTAPE_DEFAULT_MAX_EXECUTION_TIMEOUT 0
#define duk_destroy_heap_in_progress 0x01
#define duk_ctx_context_data(ctx) ((ILibDuktape_ContextData*)(ILibMemory_CanaryOK(ctx)?((void**)ILibMemory_Extra(ctx))[0]:NULL))
#define duk_ctx_nonce(ctx) (duk_ctx_context_data(ctx)->nonce)
@@ -80,6 +84,9 @@ typedef void(*Duktape_EventLoopDispatch)(void *chain, void *user);
void Duktape_RunOnEventLoop(void *chain, uintptr_t nonce, duk_context *ctx, Duktape_EventLoopDispatch handler, Duktape_EventLoopDispatch abortHandler, void *user);
#define Duktape_RunOnEventLoopEx(chain, nonce, ctx, handler, user, freeOnShutdown) Duktape_RunOnEventLoop(chain, nonce, ctx, handler, (freeOnShutdown==0?NULL:(Duktape_EventLoopDispatch)(uintptr_t)0x01), user)
void ILibDuktape_ExecutorTimeout_Start(duk_context *ctx);
void ILibDuktape_ExecutorTimeout_Stop(duk_context *ctx);
void ILibDuktape_Log_Object(duk_context *ctx, duk_idx_t i, char *meta);
char* Duktape_GetContextGuidHex(duk_context *ctx, void *db);
void Duktape_SafeDestroyHeap(duk_context *ctx);

View File

@@ -1584,19 +1584,19 @@ void *ILibDuktape_ScriptContainer_Engine_realloc(void *udata, void *ptr, duk_siz
difference = size - ILibMemory_Size(ptr);
ILibDuktape_ScriptContainer_TotalAllocations += difference;
}
if (size == 0)
{
ILibMemory_Free(ptr);
ptr = NULL;
}
else
//if (size == 0)
//{
// ILibMemory_Free(ptr);
// ptr = NULL;
//}
//else
{
ptr = ILibMemory_SmartReAllocate(ptr, size);
}
}
else
{
if (size > 0)
//if (size > 0)
{
ptr = ILibMemory_SmartAllocateEx(size, sizeof(void*));
((void**)ILibMemory_Extra(ptr))[0] = udata;
@@ -1604,6 +1604,10 @@ void *ILibDuktape_ScriptContainer_Engine_realloc(void *udata, void *ptr, duk_siz
}
}
if (ptr == NULL)
{
printf("PTR WAS NULL!\n");
}
return(ptr);
}
void ILibDuktape_ScriptContainer_Engine_free(void *udata, void *ptr)
@@ -2573,6 +2577,13 @@ duk_context *ILibDuktape_ScriptContainer_InitializeJavaScriptEngine_minimal()
#endif
ctxd->threads = ILibLinkedList_Create();
#ifdef DUKTAPE_EXECUTION_MAXTIMEOUT
ctxd->maxExecutionTime = DUKTAPE_EXECUTION_MAXTIMEOUT;
#else
ctxd->maxExecutionTime = DUKTAPE_DEFAULT_MAX_EXECUTION_TIMEOUT;
#endif
duk_context *ctx = duk_create_heap(ILibDuktape_ScriptContainer_Engine_malloc, ILibDuktape_ScriptContainer_Engine_realloc, ILibDuktape_ScriptContainer_Engine_free, ctxd, ILibDuktape_ScriptContainer_Engine_fatal);
if (ctx == NULL) { ILIBCRITICALEXIT(254); }
return(ctx);

View File

@@ -213,7 +213,7 @@ duk_ret_t ILibDuktape_EventEmitter_emit(duk_context *ctx)
int j;
int emitted = 0;
duk_require_stack(ctx, 4 + nargs + DUK_API_ENTRY_STACK); // This will make sure we have enough stack space to get the emitter object
duk_require_stack(ctx, 4 + nargs + (2*DUK_API_ENTRY_STACK)); // This will make sure we have enough stack space to get the emitter object
duk_push_this(ctx); // [object]
ILibDuktape_EventEmitter *data = (ILibDuktape_EventEmitter*)Duktape_GetBufferProperty(ctx, -1, ILibDuktape_EventEmitter_Data);
@@ -272,8 +272,12 @@ duk_ret_t ILibDuktape_EventEmitter_emit(duk_context *ctx)
{
duk_dup(ctx, j); // [object][retTable][table][array][J][func][this][..args..]
}
ILibDuktape_ExecutorTimeout_Start(ctx);
if (duk_pcall_method(ctx, nargs - 1) != 0) // [object][retTable][table][array][J][ret]
{
ILibDuktape_ExecutorTimeout_Stop(ctx);
// Invocation Error
if (strcmp(duk_safe_to_string(ctx, -1), "Process.exit() forced script termination") == 0)
{
@@ -287,6 +291,7 @@ duk_ret_t ILibDuktape_EventEmitter_emit(duk_context *ctx)
return(ILibDuktape_Error(ctx, "EventEmitter.emit(): Event dispatch for '%s' on '%s' threw an exception: %s in method '%s()'", name, objid, duk_safe_to_string(ctx, -2), Duktape_GetStringPropertyValue(ctx, -1, "name", "unknown_method")));
}
}
ILibDuktape_ExecutorTimeout_Stop(ctx);
if (!duk_is_undefined(ctx, -1)) // [object][retTable][table][array][J][ret]
{
duk_dup(ctx, -1); // [object][retTable][table][array][J][ret][ret]

View File

@@ -1,9 +1,9 @@
/*
* duk_config.h configuration header generated by genconfig.py.
*
* Git commit: d7fdb67f18561a50e06bafd196c6b423af9ad6fe
* Git describe: v2.3.0
* Git branch: master
* Git commit: fffa346eff06a8764b02c31d4336f63a773a95c3
* Git describe: v2.6.0
* Git branch: v2-maintenance
*
* Supported platforms:
* - Mac OSX, iPhone, Darwin
@@ -18,6 +18,7 @@
* - QNX
* - TI-Nspire
* - Emscripten
* - Android
* - Linux
* - Solaris
* - AIX
@@ -39,6 +40,8 @@
* - PowerPC 64-bit
* - SPARC 32-bit
* - SPARC 64-bit
* - RISC-V 32-bit
* - RISC-V 64-bit
* - SuperH
* - Motorola 68k
* - Emscripten
@@ -170,6 +173,10 @@
#define DUK_F_BCC
#endif
#if defined(ANDROID) || defined(__ANDROID__)
#define DUK_F_ANDROID
#endif
/* Linux */
#if defined(__linux) || defined(__linux__) || defined(linux)
#define DUK_F_LINUX
@@ -246,9 +253,9 @@
#endif
/* ARM */
#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)
#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__)
#define DUK_F_ARM
#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)
#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(_M_ARM64) || defined(__aarch64__)
#define DUK_F_ARM64
#else
#define DUK_F_ARM32
@@ -280,6 +287,22 @@
#endif
#endif
/* RISC-V, https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions */
#if defined(__riscv)
#define DUK_F_RISCV
#if defined(__riscv_xlen)
#if (__riscv_xlen == 32)
#define DUK_F_RISCV32
#elif (__riscv_xlen == 64)
#define DUK_F_RISCV64
#else
#error __riscv_xlen has unsupported value (not 32 or 64)
#endif
#else
#error __riscv defined without __riscv_xlen
#endif
#endif /* __riscv */
/* SuperH */
#if defined(__sh__) || \
defined(__sh1__) || defined(__SH1__) || \
@@ -356,10 +379,6 @@
#define DUK_F_VBCC
#endif
#if defined(ANDROID) || defined(__ANDROID__)
#define DUK_F_ANDROID
#endif
/* Atari Mint */
#if defined(__MINT__)
#define DUK_F_MINT
@@ -665,6 +684,41 @@
#define DUK_USE_DATE_FMT_STRFTIME
#define DUK_USE_OS_STRING "emscripten"
#elif defined(DUK_F_ANDROID)
/* --- Android --- */
#if defined(DUK_COMPILING_DUKTAPE)
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE /* e.g. getdate_r */
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE /* e.g. strptime */
#endif
#endif /* DUK_COMPILING_DUKTAPE */
#include <sys/types.h>
#if defined(DUK_F_BCC)
/* no endian.h or stdint.h */
#else
#include <endian.h>
#include <stdint.h>
#endif /* DUK_F_BCC */
#include <sys/param.h>
#include <sys/time.h>
#include <time.h>
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
#define DUK_USE_DATE_TZO_GMTIME_R
#define DUK_USE_DATE_PRS_STRPTIME
#define DUK_USE_DATE_FMT_STRFTIME
#if 0 /* XXX: safe condition? */
#define DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME
#endif
#define DUK_USE_OS_STRING "android"
#elif defined(DUK_F_LINUX)
/* --- Linux --- */
#if defined(DUK_COMPILING_DUKTAPE)
@@ -715,7 +769,7 @@
#define DUK_USE_BYTEORDER 3
#endif
#else /* DUK_F_OLD_SOLARIS */
#include <ast/endian.h>
#include <sys/param.h>
#endif /* DUK_F_OLD_SOLARIS */
#include <sys/param.h>
@@ -910,9 +964,7 @@
#elif defined(DUK_F_PPC64)
/* --- PowerPC 64-bit --- */
#define DUK_USE_ARCH_STRING "ppc64"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
/* No forced byteorder (both little and big endian are possible). */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC32)
@@ -927,6 +979,18 @@
/* SPARC byte order varies so rely on autodetection. */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV32)
/* --- RISC-V 32-bit --- */
#define DUK_USE_ARCH_STRING "riscv32"
#define DUK_USE_BYTEORDER 1
#define DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_RISCV64)
/* --- RISC-V 64-bit --- */
#define DUK_USE_ARCH_STRING "riscv64"
#define DUK_USE_BYTEORDER 1
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SUPERH)
/* --- SuperH --- */
#define DUK_USE_ARCH_STRING "sh"
@@ -1067,8 +1131,20 @@
#define DUK_USE_FLEX_ZEROSIZE
#endif
#undef DUK_USE_GCC_PRAGMAS
#define DUK_USE_CLANG_PRAGMAS
#define DUK_USE_PACK_CLANG_ATTR
#if defined(__clang__) && defined(__has_builtin)
#if __has_builtin(__builtin_bswap64)
#define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x)))
#endif
#if __has_builtin(__builtin_bswap32)
#define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x)))
#endif
#if __has_builtin(__builtin_bswap16)
#define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x)))
#endif
#endif
#elif defined(DUK_F_GCC)
/* --- GCC --- */
#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
@@ -1079,13 +1155,17 @@
#define DUK_VA_COPY(dest,src) __va_copy(dest,src)
#endif
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L)
/* since gcc-2.5 */
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L) && (DUK_F_GCC_VERSION < 50000L)
/* Since gcc-2.5.
*
* Disabled temporarily in GCC 5+ because of an unresolved noreturn-related
* issue: https://github.com/svaarala/duktape/issues/2155.
*/
#define DUK_NORETURN(decl) decl __attribute__((noreturn))
#endif
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)
/* since gcc-4.5 */
/* Since gcc-4.5. */
#define DUK_UNREACHABLE() do { __builtin_unreachable(); } while (0)
#endif
@@ -1191,6 +1271,7 @@
#define DUK_USE_FLEX_ZEROSIZE
#endif
/* Since 4.6 one can '#pragma GCC diagnostic push/pop'. */
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600)
#define DUK_USE_GCC_PRAGMAS
#else
@@ -1198,6 +1279,16 @@
#endif
#define DUK_USE_PACK_GCC_ATTR
/* Availability varies based on platform (between GCC 4.4 and 4.8), and there
* are apparently some bugs in GCC 4.x. Check for GCC 5.0 before enabling
* these to be safe.
*/
#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 50000L)
#define DUK_BSWAP64(x) ((duk_uint64_t) __builtin_bswap64((duk_uint64_t) (x)))
#define DUK_BSWAP32(x) ((duk_uint32_t) __builtin_bswap32((duk_uint32_t) (x)))
#define DUK_BSWAP16(x) ((duk_uint16_t) __builtin_bswap16((duk_uint16_t) (x)))
#endif
#elif defined(DUK_F_MSVC)
/* --- MSVC --- */
/* http://msdn.microsoft.com/en-us/library/aa235362(VS.60).aspx */
@@ -2504,7 +2595,7 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_ALIGN_BY 8
#endif
/* Compiler specific hackery needed to force struct size to match aligment,
/* Compiler specific hackery needed to force struct size to match alignment,
* see e.g. duk_hbuffer.h.
*
* http://stackoverflow.com/questions/11130109/c-struct-size-alignment
@@ -2515,6 +2606,13 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_PACK_DUMMY_MEMBER
#endif
#if !defined(DUK_U64_CONSTANT)
#define DUK_U64_CONSTANT(x) x##ULL
#endif
#if !defined(DUK_I64_CONSTANT)
#define DUK_I64_CONSTANT(x) x##LL
#endif
#if !defined(DUK_VA_COPY)
/* We need va_copy() which is defined in C99 / C++11, so an awkward
* replacement is needed for pre-C99 / pre-C++11 environments. This
@@ -2579,12 +2677,15 @@ typedef struct duk_hthread duk_context;
#define DUK_WO_NORETURN(stmt) do { stmt } while (0)
#endif
#if !defined(DUK_UNREACHABLE)
#if defined(DUK_UNREACHABLE)
#define DUK_WO_UNREACHABLE(stmt) do { } while (0)
#else
/* Don't know how to declare unreachable point, so don't do it; this
* may cause some spurious compilation warnings (e.g. "variable used
* uninitialized").
*/
#define DUK_UNREACHABLE() do { } while (0)
#define DUK_WO_UNREACHABLE(stmt) do { stmt } while (0)
#endif
#if !defined(DUK_LOSE_CONST)
@@ -2665,17 +2766,30 @@ typedef struct duk_hthread duk_context;
#endif
#endif
#if defined(DUK_F_HAVE_64BIT)
#if !defined(DUK_BSWAP64)
#define DUK_BSWAP64(x) \
((((duk_uint64_t) (x)) >> 56U) | \
((((duk_uint64_t) (x)) >> 40U) & DUK_U64_CONSTANT(0xff00)) | \
((((duk_uint64_t) (x)) >> 24U) & DUK_U64_CONSTANT(0xff0000)) | \
((((duk_uint64_t) (x)) >> 8U) & DUK_U64_CONSTANT(0xff000000)) | \
((((duk_uint64_t) (x)) << 8U) & DUK_U64_CONSTANT(0xff00000000)) | \
((((duk_uint64_t) (x)) << 24U) & DUK_U64_CONSTANT(0xff0000000000)) | \
((((duk_uint64_t) (x)) << 40U) & DUK_U64_CONSTANT(0xff000000000000)) | \
(((duk_uint64_t) (x)) << 56U))
#endif
#endif
#if !defined(DUK_BSWAP32)
#define DUK_BSWAP32(x) \
((((duk_uint32_t) (x)) >> 24) | \
((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \
((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \
(((duk_uint32_t) (x)) << 24))
((((duk_uint32_t) (x)) >> 24U) | \
((((duk_uint32_t) (x)) >> 8U) & 0xff00UL) | \
((((duk_uint32_t) (x)) << 8U) & 0xff0000UL) | \
(((duk_uint32_t) (x)) << 24U))
#endif
#if !defined(DUK_BSWAP16)
#define DUK_BSWAP16(x) \
((duk_uint16_t) (x) >> 8) | \
((duk_uint16_t) (x) << 8)
((duk_uint16_t) (x) >> 8U) | \
((duk_uint16_t) (x) << 8U)
#endif
/* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */
@@ -2698,13 +2812,6 @@ typedef struct duk_hthread duk_context;
#undef DUK_USE_GCC_PRAGMAS
#endif
#if !defined(DUK_U64_CONSTANT)
#define DUK_U64_CONSTANT(x) x##ULL
#endif
#if !defined(DUK_I64_CONSTANT)
#define DUK_I64_CONSTANT(x) x##LL
#endif
/* Workaround for GH-323: avoid inlining control when compiling from
* multiple sources, as it causes compiler portability trouble.
*/
@@ -2807,7 +2914,10 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_CACHE_ACTIVATION
#define DUK_USE_CACHE_CATCHER
#define DUK_USE_CALLSTACK_LIMIT 10000
#define DUK_USE_COMMONJS_MODULES
#define DUK_USE_CBOR_BUILTIN
#define DUK_USE_CBOR_DEC_RECLIMIT 1000
#define DUK_USE_CBOR_ENC_RECLIMIT 1000
#define DUK_USE_CBOR_SUPPORT
#define DUK_USE_COMPILER_RECLIMIT 2500
#define DUK_USE_COROUTINE_SUPPORT
#undef DUK_USE_CPP_EXCEPTIONS
@@ -2852,7 +2962,7 @@ typedef struct duk_hthread duk_context;
#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK
#undef DUK_USE_EXEC_PREFER_SIZE
#define DUK_USE_EXEC_REGCONST_OPTIMIZE
#undef DUK_USE_EXEC_TIMEOUT_CHECK
//#undef DUK_USE_EXEC_TIMEOUT_CHECK
#undef DUK_USE_EXPLICIT_NULL_INIT
#undef DUK_USE_EXTSTR_FREE
#undef DUK_USE_EXTSTR_INTERN_CHECK
@@ -2879,6 +2989,7 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_HEX_FASTPATH
#define DUK_USE_HEX_SUPPORT
#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2
#define DUK_USE_HOBJECT_ARRAY_ABANDON_MINSIZE 257
#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9
#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16
#define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8
@@ -2912,6 +3023,7 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
#define DUK_USE_MATH_BUILTIN
#define DUK_USE_NATIVE_CALL_RECLIMIT 1000
#undef DUK_USE_NATIVE_STACK_CHECK
#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY
@@ -2962,12 +3074,11 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255
#define DUK_USE_STRTAB_SHRINK_LIMIT 6
#undef DUK_USE_STRTAB_TORTURE
#undef DUK_USE_SYMBOL_BUILTIN
#define DUK_USE_SYMBOL_BUILTIN
#define DUK_USE_TAILCALL
#define DUK_USE_TARGET_INFO "unknown"
#define DUK_USE_TRACEBACKS
#define DUK_USE_TRACEBACK_DEPTH 10
#define DUK_USE_USER_DECLARE() /* no user declarations */
#define DUK_USE_VALSTACK_GROW_SHIFT 2
#define DUK_USE_VALSTACK_LIMIT 1000000L
#define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2
@@ -3383,6 +3494,9 @@ typedef struct duk_hthread duk_context;
#if defined(DUK_USE_BYTEORDER_FORCED)
#error unsupported config option used (option has been removed): DUK_USE_BYTEORDER_FORCED
#endif
#if defined(DUK_USE_COMMONJS_MODULES)
#error unsupported config option used (option has been removed): DUK_USE_COMMONJS_MODULES
#endif
#if defined(DUK_USE_DATAPTR_DEC16) && !defined(DUK_USE_DATAPTR16)
#error config option DUK_USE_DATAPTR_DEC16 requires option DUK_USE_DATAPTR16 (which is missing)
#endif
@@ -3629,6 +3743,9 @@ typedef struct duk_hthread duk_context;
#if defined(DUK_USE_UNDERSCORE_SETJMP)
#error unsupported config option used (option has been removed): DUK_USE_UNDERSCORE_SETJMP
#endif
#if defined(DUK_USE_USER_DECLARE)
#error unsupported config option used (option has been removed): DUK_USE_USER_DECLARE
#endif
#if defined(DUK_USE_USER_INITJS)
#error unsupported config option used (option has been removed): DUK_USE_USER_INITJS
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
/*
* Duktape public API for Duktape 2.3.0.
* Duktape public API for Duktape 2.6.0.
*
* See the API reference for documentation on call semantics. The exposed,
* supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API"
* comments. Other parts of the header are Duktape internal and related to
* e.g. platform/compiler/feature detection.
*
* Git commit d7fdb67f18561a50e06bafd196c6b423af9ad6fe (v2.3.0).
* Git branch master.
* Git commit fffa346eff06a8764b02c31d4336f63a773a95c3 (v2.6.0).
* Git branch v2-maintenance.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
* licensing information.
@@ -21,7 +21,7 @@
*
* (http://opensource.org/licenses/MIT)
*
* Copyright (c) 2013-2018 by Duktape authors (see AUTHORS.rst)
* Copyright (c) 2013-2019 by Duktape authors (see AUTHORS.rst)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -100,6 +100,16 @@
* * Michal Kasperek (https://github.com/michalkas)
* * Andrew Janke (https://github.com/apjanke)
* * Steve Fan (https://github.com/stevefan1999)
* * Edward Betts (https://github.com/edwardbetts)
* * Ozhan Duz (https://github.com/webfolderio)
* * Akos Kiss (https://github.com/akosthekiss)
* * TheBrokenRail (https://github.com/TheBrokenRail)
* * Jesse Doyle (https://github.com/jessedoyle)
* * Gero Kuehn (https://github.com/dc6jgk)
* * James Swift (https://github.com/phraemer)
* * Luis de Bethencourt (https://github.com/luisbg)
* * Ian Whyman (https://github.com/v00d00)
* * Rick Sayre (https://github.com/whorfin)
*
* Other contributions
* ===================
@@ -140,6 +150,8 @@
* * Neil Kolban (https://github.com/nkolban)
* * Wilhelm Wanecek (https://github.com/wanecek)
* * Andrew Janke (https://github.com/apjanke)
* * Unamer (https://github.com/unamer)
* * Karl Dahlke (eklhad@gmail.com)
*
* If you are accidentally missing from this list, send me an e-mail
* (``sami.vaarala@iki.fi``) and I'll fix the omission.
@@ -164,16 +176,16 @@
* development snapshots have 99 for patch level (e.g. 0.10.99 would be a
* development version after 0.10.0 but before the next official release).
*/
#define DUK_VERSION 20300L
#define DUK_VERSION 20600L
/* Git commit, describe, and branch for Duktape build. Useful for
* non-official snapshot builds so that application code can easily log
* which Duktape snapshot was used. Not available in the ECMAScript
* environment.
*/
#define DUK_GIT_COMMIT "d7fdb67f18561a50e06bafd196c6b423af9ad6fe"
#define DUK_GIT_DESCRIBE "v2.3.0"
#define DUK_GIT_BRANCH "master"
#define DUK_GIT_COMMIT "fffa346eff06a8764b02c31d4336f63a773a95c3"
#define DUK_GIT_DESCRIBE "v2.6.0"
#define DUK_GIT_BRANCH "v2-maintenance"
/* External duk_config.h provides platform/compiler/OS dependent
* typedefs and macros, and DUK_USE_xxx config options so that
@@ -210,6 +222,9 @@ extern "C" {
* in Duktape web documentation.
*/
#define DUK_USE_EXEC_TIMEOUT_CHECK ILibDuktape_EXEC_TIMEOUT_CHECK
duk_bool_t ILibDuktape_EXEC_TIMEOUT_CHECK(void *udata);
struct duk_thread_state;
struct duk_memory_functions;
struct duk_function_list_entry;
@@ -383,30 +398,35 @@ struct duk_time_components {
#define DUK_DEFPROP_C DUK_DEFPROP_CONFIGURABLE
#define DUK_DEFPROP_WE (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE)
#define DUK_DEFPROP_WC (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_CONFIGURABLE)
#define DUK_DEFPROP_EC (DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_CONFIGURABLE)
#define DUK_DEFPROP_WEC (DUK_DEFPROP_WRITABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_CONFIGURABLE)
#define DUK_DEFPROP_HAVE_W DUK_DEFPROP_HAVE_WRITABLE
#define DUK_DEFPROP_HAVE_E DUK_DEFPROP_HAVE_ENUMERABLE
#define DUK_DEFPROP_HAVE_C DUK_DEFPROP_HAVE_CONFIGURABLE
#define DUK_DEFPROP_HAVE_WE (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE)
#define DUK_DEFPROP_HAVE_WC (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_CONFIGURABLE)
#define DUK_DEFPROP_HAVE_EC (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE)
#define DUK_DEFPROP_HAVE_WEC (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE)
#define DUK_DEFPROP_SET_W DUK_DEFPROP_SET_WRITABLE
#define DUK_DEFPROP_SET_E DUK_DEFPROP_SET_ENUMERABLE
#define DUK_DEFPROP_SET_C DUK_DEFPROP_SET_CONFIGURABLE
#define DUK_DEFPROP_SET_WE (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE)
#define DUK_DEFPROP_SET_WC (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE)
#define DUK_DEFPROP_SET_EC (DUK_DEFPROP_SET_ENUMERABLE | DUK_DEFPROP_SET_CONFIGURABLE)
#define DUK_DEFPROP_SET_WEC (DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_ENUMERABLE | DUK_DEFPROP_SET_CONFIGURABLE)
#define DUK_DEFPROP_CLEAR_W DUK_DEFPROP_CLEAR_WRITABLE
#define DUK_DEFPROP_CLEAR_E DUK_DEFPROP_CLEAR_ENUMERABLE
#define DUK_DEFPROP_CLEAR_C DUK_DEFPROP_CLEAR_CONFIGURABLE
#define DUK_DEFPROP_CLEAR_WE (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE)
#define DUK_DEFPROP_CLEAR_WC (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE)
#define DUK_DEFPROP_CLEAR_EC (DUK_DEFPROP_CLEAR_ENUMERABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE)
#define DUK_DEFPROP_CLEAR_WEC (DUK_DEFPROP_CLEAR_WRITABLE | DUK_DEFPROP_CLEAR_ENUMERABLE | DUK_DEFPROP_CLEAR_CONFIGURABLE)
#define DUK_DEFPROP_ATTR_W (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_W)
#define DUK_DEFPROP_ATTR_E (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_E)
#define DUK_DEFPROP_ATTR_C (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_C)
#define DUK_DEFPROP_ATTR_WE (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WE)
#define DUK_DEFPROP_ATTR_WC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WC)
#define DUK_DEFPROP_ATTR_EC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_EC)
#define DUK_DEFPROP_ATTR_WEC (DUK_DEFPROP_HAVE_WEC | DUK_DEFPROP_WEC)
/* Flags for duk_push_thread_raw() */
@@ -447,18 +467,24 @@ struct duk_time_components {
* Macros to create Symbols as C statically constructed strings.
*
* Call e.g. as DUK_HIDDEN_SYMBOL("myProperty") <=> ("\xFF" "myProperty").
*
* Local symbols have a unique suffix, caller should take care to avoid
* conflicting with the Duktape internal representation by e.g. prepending
* a '!' character: DUK_LOCAL_SYMBOL("myLocal", "!123").
*
* Note that these can only be used for string constants, not dynamically
* created strings.
*
* You shouldn't normally use DUK_INTERNAL_SYMBOL() at all. It is reserved
* for Duktape internal symbols only. There are no versioning guarantees
* for internal symbols.
*/
#define DUK_HIDDEN_SYMBOL(x) ("\xFF" x)
#define DUK_GLOBAL_SYMBOL(x) ("\x80" x)
#define DUK_LOCAL_SYMBOL(x,uniq) ("\x81" x "\xff" uniq)
#define DUK_WELLKNOWN_SYMBOL(x) ("\x81" x "\xff")
#define DUK_INTERNAL_SYMBOL(x) ("\x82" x)
/*
* If no variadic macros, __FILE__ and __LINE__ are passed through globals
@@ -644,6 +670,7 @@ DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);
DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_pull(duk_context *ctx, duk_idx_t from_idx);
DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);
@@ -703,6 +730,7 @@ DUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *targ
DUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);
DUK_EXTERNAL_DECL duk_idx_t duk_push_bare_object(duk_context *ctx);
DUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);
DUK_EXTERNAL_DECL duk_idx_t duk_push_bare_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);
@@ -937,6 +965,8 @@ DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t i
DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);
#define duk_require_callable(ctx,idx) \
duk_require_function((ctx), (idx))
DUK_EXTERNAL_DECL void duk_require_constructor_call(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_require_constructable(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);
/* Symbols are object coercible and covered by DUK_TYPE_MASK_STRING. */
@@ -986,6 +1016,8 @@ DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int
/* safe variants of a few coercion operations */
DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
DUK_EXTERNAL_DECL const char *duk_to_stacktrace(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_safe_to_stacktrace(duk_context *ctx, duk_idx_t idx);
#define duk_safe_to_string(ctx,idx) \
duk_safe_to_lstring((ctx), (idx), NULL)
@@ -1010,6 +1042,8 @@ DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_cbor_encode(duk_context *ctx, duk_idx_t idx, duk_uint_t encode_flags);
DUK_EXTERNAL_DECL void duk_cbor_decode(duk_context *ctx, duk_idx_t idx, duk_uint_t decode_flags);
DUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);